PDA

View Full Version : A way to reload ALL data in an EXTJS 3.x chart



dirtdevil
8 Sep 2011, 4:45 PM
I already know how to reload data in an extjs 3.x chart but how do you reload the fields for that chart? I have an extjs 3.x stacked column chart that not only has changing data but changing fields for that data. So not only would the bars change but the number of bars and bar labels would change based on the dynamicly changing series and fields/data in the store.

I've already tried setting up an an event that would dynamicly create a new store with the new field/data in it and just replace the current store in the chart with the new one so...


Ext.Ajax.request({
url: '/taskman/core/loaduserreport/',
params: {
itemId: n.attributes.itemId
},
success: function(response){
var obj = Ext.decode(response.responseText);
console.log(obj);
Ext.getCmp('userrep').store = new Ext.data.JsonStore({
fields: obj.fields,
data: obj.data
}),
Ext.getCmp('userrep').series=obj.series;
Ext.getCmp('userrep').refresh();
},
});


And then refresh the whole chart. The chart does change, and the new column labels show up, but the columns themselves don't show up.

dirtdevil
9 Sep 2011, 8:06 AM
I wrote up an example of what I'm talking about...


new Ext.chart.StackedColumnChart({
store: [],
id: 'userrep',
xField: 'cat',
yAxis: new Ext.chart.NumericAxis({
stackingEnabled: true
}),
listeners:{
click: function(d){
console.log(d);
}
},
series: []
})

//some bla bla code
Ext.Ajax.request({
url: '/taskman/core/loaduserreport/',
params: {
itemId: n.attributes.itemId
},
success: function(response){
var obj = Ext.decode(response.responseText);
console.log(obj);
Ext.getCmp('userrep').store = new Ext.data.JsonStore({
fields: obj.fields,
data: obj.data
}),
Ext.getCmp('userrep').series=obj.series;
Ext.getCmp('userrep').refresh();
},
});



So as you can see, I setup a dummy chart and through an ajax request, I'm changing the fields as well as reloading the store. Since I need to change the fields as well as the data, I'm replacing the store. But the end result is the chart reloading with a totally different set of columns as well as fields.

dirtdevil
9 Sep 2011, 2:33 PM
bump