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

How could I update grid without refresh the whole grid

3 Answers 1104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Savin
Top achievements
Rank 1
Savin asked on 09 Mar 2017, 07:31 AM

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

3 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 10 Mar 2017, 02:06 PM
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.
0
Savin
Top achievements
Rank 1
answered on 13 Mar 2017, 08:04 AM

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. 

0
Tsvetina
Telerik team
answered on 14 Mar 2017, 02:00 PM
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.
Tags
Grid
Asked by
Savin
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Savin
Top achievements
Rank 1
Share this question
or