PDA

View Full Version : [Solved] Forcing save on a store after adding records manually



derickito
11 Nov 2010, 5:09 PM
Hi,

I've searched high and low and haven't found a solution to my particular scenario. I have an EditorGridPanel with some data on it (a schedule). The user can choose to copy over the last schedule they worked on. I'm doing this by getting the records for the last schedule through an Ajax request and then I use loadData on the store to load the data. In the Ajax request callback I'm setting all of the records to dirty. Once I do a save on the data store the records are not recognized as being dirty by the data store. Here's the callback code:


function(rs){
dstSchedule.loadData(Ext.util.JSON.decode(rs.responseText));
dstSchedule.each(function(r){
r.markDirty();
});

Is there a way to force the data store to mark its records as dirty? I'm going about this all wrong?

derickito
11 Nov 2010, 7:05 PM
Finally figured out how to do this by looking at the ExtJS code. The Store has a property called modified, which is not in the docs, where it keeps a list of modified records I simply added the records to this list in my Ajax callback:


function(rs){
dstSchedule.loadData(Ext.util.JSON.decode(rs.responseText));
dstSchedule.each(function(r){
r.markDirty();
dstSchedule.modified.push(r);
});

This doesn't seem like an elegant solution, but it works and since I've been looking at this for 2 days straight now I'm just gonna leave it at that, but if someone wants to give their 2 cents then that would be awesome.