PDA

View Full Version : How to dynamically assign a store to a Ext.chart.Panel?



cdiscla
18 Aug 2011, 3:10 AM
Hello
i want to show a chart based on parameter passed from another panel; how can i bind dynamically a store instead of assigning it during the declaration of the Ext.chart.Panel, how can i do it programmatically?

Thanks in advance and greetings
c.

philogb
18 Aug 2011, 9:26 AM
Hi - If you have a handle to the Ext.chart.Panel instance (say in a chartPanel variable), then you can access the chart and bind the store like this:




var chart = chartPanel.items.get(0);
chart.bindStore(newStore);


I hope this helps,

cdiscla
18 Aug 2011, 9:31 AM
thank you very much !

Breen
26 Sep 2011, 5:51 AM
Let's say this is my datastore



teststore = new Ext.data.Store({
model: 'testdata',
data : [
{soort: 'Niezen', waarde: 4, waarde1: 8, gem: 6},
{soort: 'Hoesten', waarde: 6, waarde1: 4, gem: 5},
{soort: 'Longaandoening', waarde: 7, waarde1: 9, gem: 8},
{soort: 'Kreupel', waarde: 5, waarde1: 2, gem: 3.5},
{soort: 'Vlekken', waarde: 5, waarde1: 9, gem: 7},
]
});


var chart = chartPanel.items.get(0);
chart.bindStore(testdata);

How can I use this?
Lets say I want the values of "waarde1" ..

Rafael Neri
10 Oct 2011, 3:35 PM
Ext.regModel('MyModel', {
fields: [{ name: 'FieldA' },
{ name: 'FieldB' },
{ name: 'FieldC' },
{ name: 'FieldD'}]
});

this.store = new Ext.data.JsonStore({
scope: this,
model: 'MyModel',
sorters: [
{
property: 'FieldA',
direction: 'ASC'
}
],
proxy: {
type: 'ajax',
actionMethods: 'POST',
url: app_relative_url + 'StoreUrl',
reader: {
type: 'json',
root: 'List'
}
},
listeners: {
load: { fn: this.initializeData, scope: this },
beforeload: { fn: this.beforeloadData, scope: this }
}
});

this.graphic = new Ext.chart.Panel({
items: [{
xtype: 'chart',
cls: 'barcombo1',
theme: 'Demo',
store: this.store,
...

20 Mar 2012, 11:28 AM
Hi - If you have a handle to the Ext.chart.Panel instance (say in a chartPanel variable), then you can access the chart and bind the store like this:




var chart = chartPanel.items.get(0);
chart.bindStore(newStore);


I hope this helps,

Thank you. This is the nugget that I have been looking for all of this time. I refreshed the store and the chart but did not know that I have to rebind the store.