Search code examples
extjsextjs4

Check if a store (or records) have been edited?


I have a Grid Panel, which when I leave the page, I want a check to see if any items in the store (or iterate through models/records) to check if there are any unsaved changes/additions.

I initially tried using panel.getStore().getNewRecords() for new records, but it returns every record currently paged in. panel.getStore().getUpdatedRecords() seems to ignore records, despite lines in the grid having the small red triangle in each cell.

So can anyone advise on the correct way to check if any new or updated records exist in a store?


Solution

  • This may work for you.

    var records = store.getRange();
    
    for (var i = 0; i < records.length; i++) {
        var rec = records[i];
    
        if (rec.dirty == true) {
            //Save data
        }
    }