PDA

View Full Version : Specifying data store load parameters



fifeflyer69
18 Jun 2012, 6:53 AM
Is there any way to pass a parameter to the tree store load method, which can then be accessible in a load event handler?

For example (using the MVC pattern):


Ext.define('Example.controller.MyController', {
init: function() {
this.control({
'mytreepanel': {
load: function(store, node, records, success, options) {
// Do something with the custom parameter...
}
}
}
},

loadLists: function() {
var store = this.getListsStore();
store.load({
customParam: true
});
}
}

Any pointers in the right direction appreciated.

sdt6585
18 Jun 2012, 7:49 AM
I'm not sure how you can do that in the mvc style control function since it doesn't seem to pass options through to the Ext.util.Observable.addListener function when it calls it. You can skip it all together though and set the event handler yourself (not in the control function) and pass anything you want in the options object according to the docs Ext.util.Observable.on (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.util.Observable-method-on)




Ext.define('Example.controller.MyController', {
init: function() {
mytreepanel.store.on('load', this.onTreeLoad, this, {
paramOne: customParam1,
paramTwo: customParam2
});
},

onTreeLoad: function (store, node, records, success, options) {
//Do something with custom param, reference it like below
options.paramOne;
}
loadLists: function() {
var store = this.getListsStore();
store.load();
}
}