PDA

View Full Version : reload store after selection



Dmoney
11 Jun 2010, 7:25 PM
I know this should be relatively easy, but I've tried searching the docs and the forum and have not found an example of this.

I have two grids and I want to change the data in the second depending on what is selected in the first.



var projectStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: 'jsonProjects.php'}),
reader: new Ext.data.JsonReader({

root: 'projectDatabase'

}, [
{name: 'projectID'},
{name: 'projectName'},
{name: 'projectDescription'},
{name: 'projectDate'},
{name: 'projectStatus'}

]),
autoLoad:true
});


That is my store code and I want to change it with something like this:


function handleRowSelect(selectionModel, rowIndex, selectedRecord) {

projectStore.reload();

}
myGrid.getSelectionModel().on('rowselect', handleRowSelect);


but I also need to change the url to something like

"jsonProjects.php?selected=" + selectedRecord

can anyone lead me in the right direction?

swarnendude
12 Jun 2010, 2:05 AM
You can use reload() function with same options you use with load(). check docs.




options : Object(optional) An Object containing loading options (http://localhost/webtop/lib/ext-3.0.0/docs/output/Ext.data.Store.html#Ext.data.Store-load) which may override the options used in the last load (http://localhost/webtop/lib/ext-3.0.0/docs/output/Ext.data.Store.html#Ext.data.Store-load) operation. See load (http://localhost/webtop/lib/ext-3.0.0/docs/output/Ext.data.Store.html#Ext.data.Store-load) for details (defaults to null, in which case the lastOptions (http://localhost/webtop/lib/ext-3.0.0/docs/output/Ext.data.Store.html#Ext.data.Store-lastOptions) are used).

Dmoney
12 Jun 2010, 9:46 AM
ok I kind of have it working I can pass the rowIndex fine and reload my grid but I need to pass the row id not the rowIndex. selectedRecord just returns object Object.

how do I get the id of the selected row?



function handleRowSelect(selectionModel, rowIndex, selectedRecord) {

projectStore.reload({params:{clientID:rowIndex}});

}

myGrid.getSelectionModel().on('rowselect', handleRowSelect);