Hi!
So I know I can do this for inline editing, a cell at a time, for example:
edit : function (e) { var data = e.model; if (data.City === "Detroit") { this.closeCell(); } e.preventDefault(); },..but if I'm using popup editing, could I disable editing depending on value?
Is there a 'closeRow()' equivalent or anything like that?
Thank you!
6 Answers, 1 is accepted
I found cancelRow() but...
edit: function (e) { var data = e.model; if (data.Status == "Optional" || data.Status == null) { e.preventDefault(); } else if (data.Status != "Optional") { this.cancelRow(); } },It's also killing the Create Row button as well... any ideas here?
Thank you!
Hello Jeff,
If you would like to distinguish the create and update operations in the edit event handler, you should use the isNew() method of the model.
E.g.
edit: function (e) { if(e.model.isNew()) { // operation is create } else { // operation is update }}Dimiter Madjarov
Telerik
I retract my answer! :)
edit: function (e) { if(e.model.isNew()) { alert('ahem!'); } else { var data = e.model; if (data.Status == "Approved") { this.cancelRow(); } else { e.preventDefault(); } }},Am I missing something here? I'll try it in a dojo as well...
Thank you!
Visually, that's pretty rough; instead, can you suggest a method for hiding the edit button on rows that possess specific criteria, something like:
var data = e.model; if (data.Status == "Approved") { $('.k-button .k-button-icontext .k-grid-edit').style.visibility="hidden"; } else { e.preventDefault(); }Thank you very much!
A more literal translation, what I'm thinking, is something in dataBound(), like this:
$("#grid tbody tr .k-grid-edit").each(function () { var currentDataItem = $("#grid").data("kendoGrid").dataItem($(this).closest("tr")); var data = e.model; if (currentDataItem.isEditable == true && data.Status == "Approved" || currentDataItem.isEditable == true && data.Thing == "OK") { $(this).remove(); }});but this isn't quite doing it; I'm not sure if I'm calling to the fields in the row correctly; any ideas?
Again, thank you very much!
Hello Jeff,
Using the dataBound event handler is the correct place to achieve the task. Here is a sample implementation, in which I am removing the edit button for specific rows.
Regards,Dimiter Madjarov
Telerik