When trying to bind the click event in the template definition itself, there are some problems with problems.
Instead, itβs easier to assign an ID link and then bind the click event later. Notice that I gave it id = create .
headerTemplate: "<a id='create' class='k-button k-button-icontext k-create-alert' id='new-item-button' title='Click to add a new item'><div>New Item</div></a>"
Then, in the document, Iβll attach the click event:
$("#create").click(function () { var grid = $("#grid").data("kendoGrid"); if (grid) {
The above function creates a new row at the bottom of the grid, manipulating the data source. Then it treats the new line as the "edit" line. The action for creating a new line was taken from OnaBai's answer here .
Jsfiddle works here , hope this helps.
source share