PDA

View Full Version : JsonStore load callback function triggering early



mjohnsonaz74
25 Apr 2011, 12:56 PM
I'm hoping that this is a simple error on my part. I'm calling a store.load and in the callback I have some code to select some checkboxes if the record indicates that they should be checked. The symptom I'm seeing is that the checkboxes are selected, but almost immediately overwritten (be a re-render?). It almost seems as if the code is being executed during the load, but then being overwritten once the load is complete.

I have the following code:

restrictUser.docGrid.store.load({
params:{userId:userId},
callback: function(r, options, success) {
var selectedRecords = new Array();
Ext.each(r, function(record, index) {
if (record.get('restricted')) {
selectedRecords.push(record);
}
});
if (selectedRecords.length > 0) {
var t = setTimeout(function(){restrictUser.docGrid.getSelectionModel().selectRecords(selectedRecords);}, 3000);
}
}
});

Without the timeout in place, the code will not select the checkboxes correctly. With the timeout, everything works fine. Does anyone have any thoughts as to why this might be happening? Has this happened to anyone before?

--MJ