PDA

View Full Version : Grid Not Displaying Latest Data?



shaoen01
17 Dec 2011, 5:30 AM
Hi All,

I have some problems with having 2 grids, with one dependent on the first grid. Is it possible to remove all rows in a grid without removing rows in the actual store attached to it? I just want to remove all the rows on the grid display.

mitchellsimoens
17 Dec 2011, 7:19 AM
Using the Array Grid example, I added this dockedItem:


dockedItems : [
{
xtype : 'toolbar',
dock : 'top',
items : [
{
text : 'Switch Store',
handler : function() {
if (grid.mainStore) {
grid.reconfigure(grid.mainStore);
delete grid.mainStore;
} else {
grid.mainStore = grid.getStore();
grid.reconfigure(Ext.data.StoreManager.lookup('ext-empty-store'));
}
}
}
]
}
]

So what it's doing in the button handler is if you want to clear out the grid, it uses reconfigure to pass in an empty store while first saving the populated store onto the grid so we don't loose it. If there is already something on grid.mainStore, then it is assumed that you want to go back to the populated store.

shaoen01
17 Dec 2011, 9:15 PM
Hi Mitchell,

Thanks for the response. I tried your code to clear the grid (which it works), but when i wanted to reload in the data, then no data gets reloaded. Even the column headers get removed as well. Any ideas?

shaoen01
17 Dec 2011, 9:28 PM
On a row select on grid 1, the listener will be fired to call populateFormGrid(poid). Inside the populateFormGrid(), i will reset some parameters and load the store. Initially, store2 is empty until a selection is made.

Changes can be made via roweditor plugin in grid2 after loading data from store2 and postback to backend to save into database. The problem i had initially was that the updates i made on grid 2 will still be showing the old values on initial load. I checked the HTTP GET when loading the store2 after i select a row, the values obtained from DB is updated but the grid 2 is not showing the updated data. I must hit a refresh (F5) on my end before the latest data get displayed on grid 2.

So i thought maybe if i remove all rows in the grid and force a reload, it would work. But so far no luck ...



Grid 1: Listener

listeners: {
'selectionchange': function(view, records) {
grid.down('#btnRemovePO').setDisabled(!records.length);

var sm = grid.getSelectionModel();
var sel = sm.getSelection()[0];

if(records[0]!=null){

populateFormGrid(poid);

}
}

}

function populateFormGrid(poid){

var pageCount=store2.getCount();
var sortDir=store2.groupDir;
var proxy=store2.getProxy();
proxy.extraParams.limit = pageCount;
proxy.extraParams.dir = sortDir;
proxy.extraParams.task = "ListProduct";
proxy.extraParams.request = "PO";
proxy.extraParams.start = 0;
proxy.extraParams.returndata = poid;

store2.load()
grid2.getView().refresh();
}

mitchellsimoens
18 Dec 2011, 3:22 AM
Hi Mitchell,

Thanks for the response. I tried your code to clear the grid (which it works), but when i wanted to reload in the data, then no data gets reloaded. Even the column headers get removed as well. Any ideas?

Was the live store the active store when you would load or the empty store?

shaoen01
18 Dec 2011, 4:22 AM
Was the live store the active store when you would load or the empty store?

Initially, the emptystore will be tagged to grid2 on load. After a selection is made on grid 1, i will then load the non-empty store into grid2. I found another way that works for me. I just toggle between the empty and non-empty store to have data displayed on grid2.




grid2.view.store=Ext.data.StoreManager.lookup('non-empty-store');

shaoen01
18 Dec 2011, 4:32 AM
Hmm, it seems to be rather buggy. The data in grid2 refreshes sometimes when updated and at times not.