Reputation: 1004
I have store which is used for grid and column chart but the values are in form of string (server side formatted amounts which cant be done at client side).due to which grid is not being rendered due to amount in string format.the solution might be make separate store with required data types for grid and chart.but this is inefficient way because same data is coming from server.
here is what i am doing
if (!window.GridModel) {
if (!Ext.ModelManager.isRegistered('GridModel')) {
Ext.define('GridModel', {
extend: 'Ext.data.Model',
fields: [{
name: 'LocCode',
type: 'string'
}, {
name: 'LocLvl',
type: 'string'
}, {
name: 'LocName',
type: 'string'
},
{
name: 'cost1',
type: 'string'
}, {
name: 'Cost2',
type: 'string'
}, {
name: 'cost3',
type: 'string'
}
]
});
}
}
for chart (not deficient)
if (!window.chartModel) {
if (!Ext.ModelManager.isRegistered('chartModel')) {
Ext.define('chartModel', {
extend: 'Ext.data.Model',
fields: [{
name: 'LocCode',
type: 'string'
}, {
name: 'LocLvl',
type: 'string'
}, {
name: 'LocName',
type: 'string'
},
{
name: 'cost1',
type: 'float'
}, {
name: 'Cost2',
type: 'float'
}, {
name: 'cost3',
type: 'float'
}
]
});
}
}
one way might be copy one store into another with changed data type of fields but i don't know how to copy one store into another with changed data type of fields.
I am using ExtJS 4.0.7
Upvotes: 2
Views: 2953
Reputation: 48236
You can have different types in the same store, but you have to load them manually, or use some trickery when loading.
Not sure if you can have totally different types, but you can use different subtypes.
Here is an example of changing store type on the fly based on the response:
http://extjs-tutorials.blogspot.ca/2012/06/polymorphic-json-change-model-subclass.html
Upvotes: 3