This is a migrated thread and some comments may be shown as answers.

kendoui-datasource change event not raised after data dataitem set

6 Answers 1361 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mayank
Top achievements
Rank 1
mayank asked on 04 Jul 2013, 06:17 PM
Hello,
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

Sort by
0
Nikolay Rusev
Telerik team
answered on 05 Jul 2013, 06:44 AM
Hello Mayank,

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

Regards,
Nikolay Rusev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alanm
Top achievements
Rank 2
answered on 26 Apr 2017, 09:33 AM

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?

0
Konstantin Dikov
Telerik team
answered on 28 Apr 2017, 07:17 AM
Hi Alanm,

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Sag
Top achievements
Rank 1
answered on 12 Oct 2018, 08:46 AM

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);
}
}
}
}

0
Konstantin Dikov
Telerik team
answered on 16 Oct 2018, 07:18 AM
Hi Sag,

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
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Sag
Top achievements
Rank 1
answered on 17 Oct 2018, 05:10 AM

Hi Dikov,

 

Many thanks for clarifying about the events. :)

Tags
Grid
Asked by
mayank
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Alanm
Top achievements
Rank 2
Konstantin Dikov
Telerik team
Sag
Top achievements
Rank 1
Share this question
or