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

Updating DataSource - Destroy Method called after sync()

2 Answers 289 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Charlie
Top achievements
Rank 1
Charlie asked on 10 Feb 2019, 10:14 PM

I have a grid that displays steps in a process.  The users are allowed to move rows up or down, reordering the steps.  If that happens a jquery method is called that updated the sequence numbers on each row.  The sequence numbers are stored with the data in the database so at the end of this process, the sync() method is called.  All works as expected except that as the Update method is called for each of the rows that was updated, the Destroy method will be called for one of the rows and the row is deleted from the database:

function resequence(grid) {
    for (var i = 0; i < grid.dataSource.data().length; i++) {
            grid.dataSource.data()[i].ActionSequenceNum = i + 1;
            grid.dataSource.data()[i].dirty = true;
        }
        grid.dataSource.sync();
}

 

I can't seem to figure out why one row is also triggering the Destroy method.

2 Answers, 1 is accepted

Sort by
0
Charlie
Top achievements
Rank 1
answered on 10 Feb 2019, 10:21 PM

More details:

Kendo Grid MVC ASP.net

C#

 

0
Charlie
Top achievements
Rank 1
answered on 11 Feb 2019, 01:51 PM
This was caused by a previous script that was removing the row and then reinserting in to accomplish the re-order.  The removal caused the destroy to fire.  Solution was to remove the default Destroy behavior and code my own Delete function.
Tags
Data Source
Asked by
Charlie
Top achievements
Rank 1
Answers by
Charlie
Top achievements
Rank 1
Share this question
or