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

2 posts, 0 answers
  1. Naga
    Naga avatar
    25 posts
    Member since:
    Jul 2015

    Posted 12 May 2016 Link to this post

    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

  2. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2596 posts

    Posted 14 May 2016 Link to this post

    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!
     
Back to Top