How could I update grid without refresh the whole grid

4 posts, 0 answers
  1. Savin
    Savin avatar
    2 posts
    Member since:
    Dec 2015

    Posted 09 Mar 2017 Link to this post

    Hi guys,

    I have a MVVM grid. it has a save event to update some columns by edit another column, but only while refresh() run they are updated and shown in the grid, which is very not user friendly. Could you tell me how to update these and won't refresh the whole grid so that the scroll won't be moved? Thanks.

    Here is my code:

     changeApprovedFOB: function (e) {
            debugger;
            var data = e.model;
            if (e.values.APPROVED_FOB != undefined) {
                data.QUOTATION_PREMIUM_DISCOUNT = data.MANUAL_FOB == 0 ? 0 : (Math.round((data.QUOTATION_FOB - data.MANUAL_FOB) / data.MANUAL_FOB) + "%");

                if (e.values.APPROVED_FOB != 0) {
                    data.APPROVED_PREMIUM_DISCOUNT = data.MANUAL_FOB == 0 ? 0 : (Math.round((e.values.APPROVED_FOB - data.MANUAL_FOB) / data.MANUAL_FOB) + "%");
                }

                this.QuotationDataSource.pushUpdate(data);

                $('#Grid').data('kendoGrid').refresh();
            }
            else {
                this.QuotationDataSource.pushUpdate(data);
            }
        }

  2. Tsvetina
    Admin
    Tsvetina avatar
    2481 posts

    Posted 10 Mar 2017 Link to this post

    Hi Savin,

    If you do changes in the Grid that you want to reflect in the backend, you should call the sync() method of the Grid DataSource. This will trigger an update of the Grid, but this is needed to ensure that the Grid is in sync with the backend data. By default the Grid persists its scroll position automatically, as you can see in this demo:
    Grid / Inline editing

    If there is some specific about your Grid that prevents it from keeping its scroll position, you can try the suggestion from this post:
    Data Source Update Resets Grid Scollbar

    Regards,
    Tsvetina
    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.
  3. Savin
    Savin avatar
    2 posts
    Member since:
    Dec 2015

    Posted 13 Mar 2017 in reply to Tsvetina Link to this post

    Hi Tsvetina,

          Thank you for your reply. Seems confirmation is necessary before saving. Have no a method to refresh the column only? If no, maybe I will talk with Users to Confirm. 

  4. Tsvetina
    Admin
    Tsvetina avatar
    2481 posts

    Posted 14 Mar 2017 Link to this post

    Hello Savin,

    Looking at your code again, I notice that you are not setting the model values using the set methode.model is an ObservableObject representing the Grid data item and if you don't use set() to apply its new value, the Grid will not be notified about the change.
    data.set("QUOTATION_PREMIUM_DISCOUNT", someValue);

    Give this a try and let me know if this addresses the problem.

    Regards,
    Tsvetina
    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.
Back to Top