javascript - Preventing editing a row in kendo grid? -
i using kendo grid , while editing row checking whther row editable or not.so how make selected row non editable if not editable.i doing checking in edit
function of grid.
code
$("#grid").kendogrid({ datasource : ds, selectable : "multiple", sortable : true, filterable : false, reorderable: true, scrollable : false, toolbar : ["create"], columns: [ { field: "event", width: "120px", title: "event type"}, { field: "event_id", width: "120px", title: "event id"}, { field: "addr_no_or_type", width: "120px", title:"address"}, { field: "event_rate", width: "100px", title: "rate"}, { field: "sched_date", width: "100px", title: "scheduled"}, { field: "complete_date", width: "100px", title:"completed"}, { field: "serial_no", width: "100px", title: "serial #"}, { command: ["edit", "destroy"], title: "options", width: "170px"} ], editable: "inline", edit : function(e){ selectedrowindex = $("#grid").data("kendogrid").select().index(); if (selectedrowindex >= 0) { var grid = $("#grid").data("kendogrid"); var selecteditem = grid.dataitem(grid.select()); var slno = selecteditem.serial_no; if(slno!=0){ grid.cancelrow(); } } } });
but when use i'm getting following error in console.
uncaught typeerror: cannot call method 'delegate' of null
can suggest method resolve it.thank you.
in current case suggest use databound event iterate on datasource view data , check if current record met given condition disable it's edit button:
function ondatabound(e) { //this solution makes rows editable / not editable var grid = e.sender; var data = grid.datasource.view(); (var = 0; < data.length; i++) { //check custom condition if (data[i].orderid % 2 == 0) { var editbutton = grid.tbody.find("tr[data-uid='" + data[i].uid + "'] .k-grid-edit"); editbutton.addclass("k-state-disabled").removeclass("k-grid-edit"); //or //grid.tbody.find("tr[data-uid='" + data[i].uid + "'] .k-grid-edit").remove(); } } }
Comments
Post a Comment