PDA

View Full Version : Pie chart with datagrid



ruchika
24 Apr 2009, 6:12 AM
Hi,
I am trying to display a pie chart and a grid by dynamically fetching data from the db. I am using the same datastore for both the components. can some one help me for the same.
the code used for the same is:
#var datastore = new Ext.data.JsonStore({
url: '/ext/testServlet',
root: 'emp.data',
id: 'emp',
totalProperty: 'emp.totalRows',
baseParams: {'action': 'emp'},
fields: [
{name: 'empId'}
,{name: 'name', type: 'string'}
,{name: 'company', type: 'string'}
]
});
var grid = new Ext.grid.GridPanel({
store: datastore,
columns:[
new Ext.grid.RowNumberer()
,{id:"empId", header: "Employee ID", width: 75, sortable: true,renderer : change, dataIndex: 'empId'}
,{header: "Name", width: 75, sortable: true, dataIndex: 'name'}
,{header: "Company", width: 100, sortable: true, dataIndex: 'company'}

],
width:1100,
height: 350,
frame:true
});
var piecht = new Ext.Panel({
iconCls:'chart',
title: 'Simple chart',
frame:true,
width:600,
height:300,
items: {
xtype: 'piechart',
store:datastore
}
});
function LoadAndShowGrid(combovalue,clientcombo){
// render the grid
grid.render(document.body);
// configure callback
grid.getStore().on('load', loadSuccessful);
// load the store
grid.getStore().load({params: {'fetchfromDb': fetchDb,'batch':combovalue }});
// render the chart
piecht.render(document.body);
piecht.getStore().on('load', loadSuccessful);
piecht.getStore().load({params: {'fetchfromDb': fetchDb,'batch':combovalue }});

}#

Thanks

tryanDLS
24 Apr 2009, 6:15 AM
http://extjs.com/learn/Ext_Forum_Help#How_to_post_code_properly

shibubh
24 Apr 2009, 5:55 PM
first verified whether or not the store is Loaded.