PDA

View Full Version : extended stores problem



EducatedFool
8 Jun 2010, 6:53 AM
MyApp.TeamObject.store = new Ext.data.Store({
id: 'resultsDataStore',
proxy: new Ext.data.HttpProxy({
url: '/' + module + '/' + controller + '/index/',
method: 'GET'
}),
baseParams: {}, reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'team_id'
}, [{
name: 'team_id',
type: 'int'
},{
name: 'club_id',
type: 'int'
},{
name: 'name',
type: 'string'
}]),
remoteSort: true
});



So now, I can use MyApp.TeamObject.store in a grid, in a dropdownmenu, combobox, ...


grid :



MyApp.TeamObject.teamGrid = Ext.extend(Ext.grid.GridPanel, {
initComponent: function () {
Ext.apply(this, { /* store */
store: MyApp.TeamObject.store
...




form:




{
store: MyApp.TeamObject.store,
fieldLabel: 'Team',
displayField: 'name,
valueField: 'team_id',
hiddenName: 'team_id',
forceSelection: true,
mode: 'remote',
triggerAction: 'all',
selectOnFocus: true,
editable: false,
xtype: 'combo'
}




I just found out that there is one problem. Let's say I sort the data on a column in the grid, then the data is also sorted in my other items eg dropdownmenu,...
I know why, but I can't find a decend solution for my problem. Anyone a good idea? Knows how I need to do this? Is my way a good way to develop?

Condor
8 Jun 2010, 7:08 AM
Modifying a store will affect all attached components. If that is undesireable then you will need to make a copy of the store before using it.

evant
8 Jun 2010, 7:15 AM
Don't put object instances in the prototype of a class. It means they will be shared over all instances.