Hi,I have tried to use the following approach as discussed in this forum,
Code:
colModel.rows = ds.meta.rows;colModel.setConfig(ds.columns);
The same is not working for me i have tried to evoke it from both the viewConfig onDataChange and the stores load listener, but in both cases my grid is only loading with the normal column structure and the header columns are not being foundmy js code is :
Code:
var overViewGridStore = new Ext.data.JsonStore({ fields : [], url : overViewGridStoreUrl, autoLoad : true, listeners : { load : function() { //Ext.getCmp('overViewGrid').getColumnModel().rows = this.reader.jsonData.metaData.headers;; //Ext.getCmp('overViewGrid').getColumnModel().setConfig(this.reader.jsonData.columns); alert(Ext.getCmp('overViewGrid').getColumnModel().rows); }, exception : function() { Ext.MessageBox.show({ icon : Ext.MessageBox.ERROR, buttons : Ext.MessageBox.OK, msg : "Please contact the administrator.", title : 'Error' }); } } }); var group = new Ext.ux.grid.ColumnHeaderGroup({ rows : [] }); var overViewGrid = new Ext.grid.GridPanel({ title : 'grid', anchor : '100% 100%', id : 'overViewGrid', store : overViewGridStore, autoScroll : true, columns : [], viewConfig:{ forceFit : true, onDataChange: function (){ // this.cm.rows = this.ds.reader.jsonData.metaData.headers; // this.cm.setConfig(this.ds.reader.jsonData.columns); } } plugins : group });
and my JSON data from server is of the form
Code:
{ "metaData": { "headers": [ { "align": "center", "colspan": "1" }, { "align": "center", "header": "xxxxx", "colspan": "5" } ], "idProperty": "transaction", "root": "root", "fields": [ { "mapping": "transaction", "name": "transaction" }, { "mapping": "time1", "name": "time1" }, { "mapping": "count1", "name": "count1" }, { "mapping": "rt1", "name": "rt1" }, { "mapping": "xcount1", "name": "xcount1" }, { "mapping": "xrt1", "name": "xrt1" } ] }, "root": [], "columns": [ { "align": "center", "header": "Transactions", "dataIndex": "transaction", "sortable": "true", "hideable": "false", "id": "transaction" }, { "align": "left", "header": "Time", "dataIndex": "time1", "sortable": "true", "hideable": "false", "id": "time1" }, { "align": "left", "header": "Count", "dataIndex": "count1", "sortable": "true", "hideable": "false", "id": "count1" }, { "align": "left", "header": "Response Time", "dataIndex": "rt1", "sortable": "true", "hideable": "false", "id": "rt1" }, { "align": "left", "header": "Failed Count", "dataIndex": "xcount1", "sortable": "true", "hideable": "false", "id": "xcount1" }, { "align": "left", "header": "Failed Response Time", "dataIndex": "xrt1", "sortable": "true", "hideable": "false", "id": "xrt1" } ]}
I am able to render the followinggrid.jpg