How to delete rows from a wijmo grid in a loop and refresh?

914 Views Asked by At

Is there a way we can delete rows from a wijmo grid running within a loop and refresh the grid with new data. I tried with the following approach, I can see the rows getting deleted while debugging but after the loop ends the grid is refreshed with old set of data.

   self.delete = function (obj, event) {

            var pagesize = $("#pageDisplay :selected").val();// 5
            var pageSizeDiff = defaultPageSize - pagesize;//5
            var $grid = $("#Grid");
            var newData = $grid.wijgrid("data");// array of 10 objects
            var i = 0;
            while (i < pagesize) {
                newData.splice(pageSizeDiff, 1);// delete from 5th row
                $grid.wijgrid("data", newData);

                //refresh grid
                $grid.wijgrid("ensureControl", true);
                i++;
            };                
        };
1

There are 1 best solutions below

1
On

I am not sure why you are setting the new data in the loop. Ideally, you should delete the rows in the loop and then, set the new data.