PDA

View Full Version : JsonStore (remote) + JsonStore (local) + Window = misery!



cherrio
13 Mar 2011, 1:15 AM
Hi All,

I am trully stumpped and was wondering if any gurus can help me out. To explain the concept. Server provides a list of files that are stored JsonStore called "FileStore" (remote). The user can select rows on the Grid and these selections (records!) get put into the local JsonStore called "SelectedFileStore" (local). Now the user can press a button a popup window appears with a new grid that is connected to SelectedFileStore.

Sounds simple right? And it works fine, unless I want to have all the records selected/checked by default. (i.e. this.popupFileGrid.getSelectionModel().selectAll(); )

After some googling a couple of posts suggested it was a timing issue, so I tried to use events like "afterrender" to, but I constantly get the same error (from Firebug console),


this.grid is undefined
for(var i = 0, len = this.grid.store.getCount(); i < len; i++){ ext-all-debug.js (line 49400)

If I instead run selectAll from the parent class (i.e. that creates the window instance), it will "check" each line, but it "looks" like they are not selected, when infact they are (have to click twice to get each row selected). If I sort them (locally) then they render correctly (as checked).



var win = new popupWindow({
fileGrid: this.fileGrid
});
win.show();

win.popupFileGrid.getSelectionModel().selectAll();

Totally stumped, any ideas?



FilesStore = function(cfg) {
cfg = cfg || {};
FilesStore.superclass.constructor.call(this, Ext.apply({
storeId: 'FileStore',
root: 'READ',
proxy : new Ext.data.HttpProxy({
method: 'POST',
url: settings.url
}),
sortInfo: {
field: 'dated',
direction: 'DESC' // or 'ASC' (case sensitive for local sorting)
},
remoteSort: true,
//params: {limit: 10},
totalProperty: 'META.total',
fields: ["type","name","size","id"]
}, cfg));
};

Ext.extend(FilesStore, Ext.data.JsonStore, {});
new FilesStore();

SelectedFileStore = Ext.extend(Ext.data.ArrayStore, {
constructor: function(cfg) {
cfg = cfg || {};
SelectedFileStore.superclass.constructor.call(this, Ext.apply({
storeId: 'SelectedFileStore',
proxy: new Ext.data.MemoryProxy(),
fields: ["type","name","size","id"],
autoLoad: false,
sortInfo: {
field: 'dated',
direction: 'DESC' // or 'ASC' (case sensitive for local sorting)
},
remoteSort: false
}, cfg));
}
});
new SelectedFileStore ();
Handlers for the main FileGrid, add/remove record from selectionStore as needed.


HandleFileSelected = function (selectionModel, rowIndex, record){
this.selectionStore.add(record);
};


HandleFileDeselected = function (selectionModel, rowIndex, record){
this.selectionStore.remove(record);
};
Thanks in advance!!