I set the kendo datacolumn value using javascript like ,
var gridData = $("#GridName").data("kendoGrid");
var tr = $("#GridName tbody tr[1]");
var idx = tr.index();
gridData._data[idx].VATEntryCode = 0;
$("#GridName").data("kendoGrid").refresh();
data value successfully updated on grid but datasource change event not raised.
$(gridName).data("kendoGrid").dataSource.bind("change", function (e) {
});
suggest me what i missing?
Thanks
Mayank
6 Answers, 1 is accepted
If need DataSource.change event to trigger you need to modify the data inside DataSource by using set method of the underlying object.
Here is a sample for that: http://jsbin.com/erazoy/1/edit
Nikolay Rusev
Telerik
Hi, this works ok for changing the whole row data, but is there any way of specifically 'setting' the data on an individual cell level.
Your example is only changing the value in the 'text' column for for the first row for example but the whole row data needs to change according to your example?
The set method of the Model changes the value for a specific field in the model, which from what I understnad is what you are trying to achieve:
dataItem.set("fieldName", value)
If you have something different in mind, please provide more information on the exact requirement.
Regards,
Konstantin Dikov
Telerik by Progress
Hi,
What if we try to loop through the dataSource object and try to set the data in one of the objects (like the below code). How to the "save", "edit", "change" events trigger in this scenario?
var dataSource = $("#quoteDetailGrid").data("kendoGrid").dataSource;
var data = dataSource.data();
if (data != null && data.length > 0) {
for (var count = 0; count < data.length; count++) {
if (data[count].LineItemType != null) {
var anteil = data[count].ListAmount / totalList;
if (anteil != 0) {
data[count].set("TotalDiscountAmount", 50);
}
else {
data[count].set("ManualDiscount", 0);
}
}
}
}
Using the "set" method will trigger only the "change" event of the dataSource. The "save" and "edit" events are part of the Grid's API and they will not fire when the "set" method is used.
Best Regards,
Konstantin Dikov
Progress Telerik
Hi Dikov,
Many thanks for clarifying about the events. :)