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

compare grid rows and result data and remove from grid if common

1 Answer 160 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Naga
Top achievements
Rank 1
Naga asked on 12 May 2016, 05:16 PM

I have grid with X number of rows. Whenever i the grid is bound with a dataset,  i need to make sure that the records present in Grid should be removed and add only records from data set 

For eg: if ID 102  is already present in grid as well as it is present in new result set, while adding additional details, grid should remove 102 and add it from the new result set. 

I wrote the below code to do this . but this is very performance inefficient, when i have 100 records in the grid and new result set adds another 100 records, this is hanging the page. 

Please help. 

                var gridExistingData = datasource.data();
                        $.grep(gridExistingData, function (d) {
                            if (resultData.length > 0) {
                                if (d != null && d.AssetID == resultData[i].AssetID) {
                                    gridExistingData.remove(d);
                                }
                            }
                        });

Please suggest if there is any alternative process to achieve this

1 Answer, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 14 May 2016, 06:44 AM
Hello,

I would suggest you to use the pushDestoy() method and remove the records at once, as documented here:


http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-pushDestroy
Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Naga
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or