Question

I was working with a Kendo Editor Template in two seperate solutions, where I created my template as the below

@using Kendo.Mvc.UI
@(Html.Kendo().NumericTextBox()
.Min(0)
.Decimals(0))

Now, to use that as an Editor Template in Razor syntax, I attach it to a column as below:

columns.Bound(p => p.SomeField).EditorTemplateName("NumericTextBoxEditor");

All works fine and I have my numeric text box that doesn't allow non-numeric input. If I try the same thing by declaring columns in Javascript, I can't get it to work. Is there any way to set the correct editor template e.g.

var myColumns = [];
myColumns.push({
  width: 100,
  editor: "NumericTextBoxEditor"
});

Or will it never know about the editor template due it being server side?

Was it helpful?

Solution

Or will it never know about the editor template due it being server side?

This is correct.

In JS, column.editor has to be a function, so you can't directly use server-side editor templates. The equivalent would be something like this:

columns: [{
    field: "fieldName",
    editor: function (container, options) {
        var input = $('<input name="' + options.field + '" />');
        input.appendTo(container);
        input.kendoNumericTextBox({
            min: 0,
            decimals: 0
        });
    }
}],
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top