PDA

View Full Version : How to change the root of store, based on active panel of accordion layout.



seema
20 Dec 2011, 3:05 PM
Hi,
I have a accordian layout panel. It has two panels, "partner" and "contacts". data for both panel is comming from the same proxy. only the root will different based on selected panel. how could I achieve this.
here is my code-


layout: {

type: 'accordion',

fill: true

},

defaults: {

collapsed: true,

autoHeight: true

},

layoutConfig:{

animate: true

},
items: [{

xtype: 'panel',

title:'Partners',

id:'partner',

autoScroll: true,

border: false,

items: [Ext.sidebar.partnerFilter]

},

{

xtype: 'panel',

title:'Contacts',

autoScroll: true,

border: false,

items: [Ext.sidebar.contactFilter]

}

],

listeners: {

expand: function() {

populateModelForFilter();

},

render: function(thiselement) {

populateModelForFilter();

}

}



Here is my populateModelForFilter function and proxy definition



populateModelForFilter=function(){

if(filterOn == 'partner'){
filterRoot='partnerFilter.column';
}else if(filterOn =='contacts'){
filterRoot='contactFilter.column';

}
}



here is the code for store


varproxyData = new Ext.data.HttpProxy({

url: '/api/filter.json',

reader: {

type: 'json',

root: 'pdb.user.filterResults.'+filterRoot

}

});


var strData = new Ext.data.JsonStore({

model: 'filterModel',

proxy: proxyData,

autoLoad: true

});



Problem is its not picking root dynamically. I'm getting the return from store but not getting my data in model.

Please suggest

mitchellsimoens
20 Dec 2011, 3:19 PM
Easiest way would be to have two separate stores.

seema
20 Dec 2011, 3:22 PM
I know, but in this scenario, I have to pick whole data in one go and then have to display it based on root.

mitchellsimoens
20 Dec 2011, 3:25 PM
So you get both datasets in one call?

seema
20 Dec 2011, 3:37 PM
My data will be like that



{"pdb":{"user":{"filterResults":
{"partnerFilter":{"column":[{"id":"HomeGeography","name":"Home GEO","filterValues":[{"id":"EMEA","displayName":"EMEA"}]}]}},
{"contactFilter":{"column":[{"id":"businessModel","name":"Business Model","filterValues":[{"id":"reslller","displayName":"Reslller"}]}]}}
}}}


based on the active panel, I have to pick either from "pdb.user.filterResults.partnerFilter.column" or "pdb.user.filterResults.contactFilter.colum " root

mitchellsimoens
20 Dec 2011, 3:47 PM
I would create two separate stores that get their data from an Ajax call.

seema
20 Dec 2011, 3:54 PM
Is there any way to get the title or id of expanded panel in accordion layout?