PDA

View Full Version : ExtDesigner with custom store



BuckBazooka
13 Apr 2010, 7:33 AM
Hi,
I am using ExtDesigner. I want to create a store, which is using a url given by a variable. Not statically entered in the tool. Also I need to specify some extra parameters before the call to load is sent. With normal js it is easy. But what is the approach to solve these problems when we use ExtDesigner? The js containing the store defined by the designer is generated each time one export the data, so it is not the right place to edit. How should I solve these problems?

Any suggestions? Again, thanks for your advice.

aconran
13 Apr 2010, 10:08 AM
In the latest release (1.0.0.8), all stores accept a configuration which will overwrite the default configs. You can create instances of your store type in the implementation classes and provide custom urls etc.

Perhaps we should add an option in the store tab, "Create instance of this store" which would create the instance in the code gen.

BuckBazooka
14 Apr 2010, 1:32 AM
Thanks again Aaron for your reply.

I'm not sure to understand completely what you mean. I use now the cfg when I call the constructor to overwrite the defaults which I need to set. But I still have one remaining problem.

In MyStoreClass.js file the designer instantiates the store. In my case the store should not be instantiated as soon as the javascripts are loaded, as I will need to instantiate this store only once I know more details about what the user wants to do.



...
* This file will be auto-generated each and everytime you export.
*
* Do NOT hand edit this file.
*/

FreePriceElementStore = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
FreePriceElementStore.superclass.constructor.call(this, Ext.apply({
storeId: 'FreePriceElementStore',
idProperty: 'id',
sortField: 'country',
autoLoad: true,
remoteSort: true,
sortDir: 'ASC',
root: 'results',
fields : [
{
name: 'country',
mapping: 'priceComponent.country'
},
{
name: 'modificationDate',
dateFormat: 'd/m/Y H:i:s',
type: 'date'
},
{
name: 'id'
},
{
name: 'priceComponent'
}
]
}, cfg));
}
});
new FreePriceElementStore(); // <<<<<<<< I need to remove this.


I instantiate this class in my code like this:


FreeElementsWindow = Ext.extend(FreeElementsWindowUi, {
initComponent: function() {
new FreePriceElementStore({
url:zenurl.salesadmin_getContractFreeElementRecords,
autoDestroy:true,
listeners:{
beforeload: function(store, options){
options.params["contract.id"] = this.contract.id;
},
scope:this
}
});

FreeElementsWindow.superclass.initComponent.call(this);
this.addFreeElementsBtn.on("click", this.onAddFreeElementsBtn, this);
},
onAddFreeElementsBtn: function(){
console.log("onAddFreeElementsBtn");
},
....


I think for me the current implementation of the designer would be fine if I could tell it not to instantiate the store. I can only instantiate this store once I know which contract the user selected. Once I know this I can show the grid and instantiate the store with the proper parameters to be sent. Do I make sense? Thanks

aconran
14 Apr 2010, 5:52 PM
Yes, this makes sense and we will add this as an option.

BuckBazooka
14 Apr 2010, 11:36 PM
Great Thanks.