asp.net mvc - data-bind not working in kendo.template -
i'm having troubles trying implement custom remove button in kendo grid. code have:
view:
<div id="gridadditionallines">
javascript:
var datasourcegrid = new kendo.data.datasource({ data: mydata, --> it's type of kendo.observable schema: { model: { id: "id", fields: { id: { editable: false, nullable: true }, column1: { editable: false, nullable: true }, description: { validation: { required: true} }, value: { validation: { required: true} } } } } }); $("#mygrid").kendogrid({ datasource: datasourcegrid, editable: true, navigatable: true, toolbar: ["create"], columns: [ { field: "description" }, { field: "value" }, { command: [{name: "destroy", template: kendo.template($("#deletetemplate").html())}], width: 60} ] });
this template i'm using remove button each row:
<script type="text/x-kendo-template" id="deletetemplate"> <button class="btn btn-default" data-bind="click: applicability.deleteline"> <span class="glyphicon glyphicon-remove"></span> </button>
with code above, kendro grid display data properly. however, when trying remove row, @ moment click in remove button, nothing happens.
do missing something?
your function button click missing here. once add script button added grid, happens when click on button not specified
<script type="text/x-kendo-template" id="deletetemplate"> <button class="btn btn-default" data-bind="click: applicability.deleteline"> <span class="glyphicon glyphicon-remove"></span> </button>
then have add onclick function button:
$('.btn.btn-default').on('click', function() { var grid = $("#grid").data("kendogrid"); var dataitem = grid.dataitem($(this).closest("tr")); if(confirm('are sure want delete : ' + dataitem.name)) { grid.datasource.remove(dataitem); grid.datasource.sync(); grid.refresh(); } });