PDA

View Full Version : How to change Store parameter on Ext.NestedList in itemtap



foton
20 Aug 2011, 6:53 PM
Hi all,

Just to the point, I create menu using Ext.NestedList. At first load it can display menu items on the nested list as expected. But each time I select item (itemtap) the nested list seems create new request to server and load the same json as the first time , because in this case I don't put/make change to param of store.

Here is my code :




nnt.store.MenuTreeStore = Ext.extend(Ext.data.TreeStore, {
constructor: function (config) {
config = Ext.apply(config || {}, {
listeners: {
beforeload: function (store, operation) {
console.log('beforeload called ....');
//debugger;

var proxy = store.getProxy();
//proxy.url = "new url";
},
scope: this
}
});

nnt.store.MenuTreeStore.superclass.constructor.call(this, config);
}
});

sink.StructureStore = new nnt.store.MenuTreeStore({
model: 'Demo',
id:'menuStructureStore',
proxy: {
type: 'ajax',
url: 'Home/GetMenu',
reader: {
type: 'tree',
//type:'json',
root: 'root'
}
},
clearOnPageLoad: false,
autoLoad:false
});

this.navigationPanel = new Ext.NestedList({
store: 'menuStructureStore',
useToolbar: Ext.is.Phone ? false : true,
updateTitleText: false,
dock: 'left',
hidden: !Ext.is.Phone && Ext.Viewport.orientation == 'portrait',
toolbar: Ext.is.Phone ? this.navigationBar : null,
listeners: {
selectionchange: function () {
console.log("Log on SelectionChange");
},
itemtap: function () {
console.log("Log on ItemTap");
},
beforeselect: function () {
console.log("Log on BeforeSelect");
}
}
});



My question :

Is this behavior (each time item on nested list always make new request to server) normal/characteristic of nested list or not??? If not, am I missing something in my code to avoid the nested list make new request each time select item ???
If nested list create new request each time item selected (itemtap), how to change store parameter proxy before the store make request ? Because on my logger output while tracing event order is :

beforeload (in store)
itemtap (in nested list)
beforeselect (in nested list)




Thanks in advance.