kendoui-datasource change event not raised after data dataitem set

7 posts, 0 answers
  1. mayank
    mayank avatar
    11 posts
    Member since:
    Sep 2012

    Posted 04 Jul 2013 Link to this post

    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
  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 05 Jul 2013 Link to this post

    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!
  3. Alanm
    Alanm avatar
    26 posts
    Member since:
    Mar 2007

    Posted 26 Apr 2017 in reply to Nikolay Rusev Link to this post

    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?

  4. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 28 Apr 2017 Link to this post

    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.
  5. Sag
    Sag avatar
    10 posts
    Member since:
    Jun 2018

    Posted 12 Oct 2018 in reply to Konstantin Dikov Link to this post

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

  6. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 16 Oct 2018 Link to this post

    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.
  7. Sag
    Sag avatar
    10 posts
    Member since:
    Jun 2018

    Posted 17 Oct 2018 in reply to Konstantin Dikov Link to this post

    Hi Dikov,

     

    Many thanks for clarifying about the events. :)

Back to Top