0

I'm trying to populate an editable kendo grid. In all examples I see e.g. http://demos.telerik.com/aspnet-mvc/grid/editing-inline , the inline editor cells seem to be normally displayed as kendoNumericTextBox.

I'm looking e.g. at this example (approved answer) Kendo UI Grid Conditional editing, where it is accessed in the following way:

e.container.find("input[name=DiscountPercentageMRC]").data("kendoNumericTextBox")

Apart from this jsFiddle I cannot access the numeric textboxes in this way. Where can the problem be?

Community
  • 1
  • 1
Turo
  • 1,537
  • 2
  • 21
  • 42

1 Answers1

1

Judging by the two versions of the question, I assume that you are asking why sometimes the edit textboxes are Kendo UI textboxes (e.g. NumericTextBox or Kendo-UI-styled input), and sometimes are plain inputs.

When the Kendo UI MVC Grid wrapper is used, the editor widgets depend on the following:

  • the default ASP.NET MVC editors for specific data field types.
  • the editor template files placed in the /EditorTemplates/ folder(s).

Probably you don't have the Kendo UI editor template files in your application, that's why no Kendo UI widgets are used in edit mode. Please verify that.

The built-in Kendo UI editor templates are avaialble in the wrappers/aspnetmvc/EditorTemplates folder of the "UI for ASP.NET MVC" installation.

http://docs.telerik.com/kendo-ui/aspnet-mvc/introduction#distribution-contents

Here is how to use them or create your own editor templates:

http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/templating/editor-templates

After you have the Kendo UI widgets being used as editors, you can access them in the Grid's edit event like this:

http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Editing/access-editor-control

Plain textbox editors and Kendo-UI-styles plain inputs are accessed as standard input elements via the respective field name. No .data('kendoWidgetName') method is needed:

var productNameTextBox = e.container.find("[name=ProductName]");
dimodi
  • 3,969
  • 1
  • 13
  • 23
  • thank you dimodi it is useful. I followed your advice and added the templates to Views/Shared/EditorTemplates folder - now (or I believe only now) I get textboxes as kendo elements, but numeric text boxes still as plain text boxes. Some ideas? – Turo Aug 20 '16 at 17:33
  • 1
    thank you. It turns out that for integer type I needed to explicitly add [UiHint("Integer")] annotation to my viewModel and for decimal define a new editorTemplate, which does not come out the box. Other number types work without data annotations based on kendo supplied editorTemplates, a bit strange. – Turo Aug 21 '16 at 21:13