-
20 Dec 2010 2:07 AM #1
GroupHeader from json
GroupHeader from json
hai extjs..
i have load header coloumn from database and then i want to make header coloumn into groupHeader
Example like this..
|1000 | 2000 | from json storeHTML Code:| 1000 |2000 | ----------------------------------------------- | a |b | a | b| -----------------------------------------------
here is my code
i useCode:function apply() { Ext.Ajax.request({ url: baseHref + newhid.fluid_consumption_analysis.controller + '/get_header', params: this.getForm().getValues(), scope: this, success: function(resp, options) { resp = Ext.decode(resp.responseText); countTab = resp.length; var colHeader = new Array(); for (i=0;i<countTab;i++) { colCount = resp[i].colHeader.length; Ext.getCmp('cpt_grid').destroy(); var grid = new newhid.fluid_consumption_analysis.grid(); grid.render('fluid_analysis'); for(c=0;c<colCount;c++) { comp_mod = resp[i].colHeader[c].header; arr = resp[i].colHeader[c].header; storex = (Array({'name':resp[i].colHeader[c].header})); grid.addColumn({name:storex},{header: comp_mod}); } } } }); }and this my groupHeaderCode:Ext.override(Ext.grid.ColumnModel,{ addColumn: function(column, colIndex){ if(typeof column == 'string'){ column = {header: column, dataIndex: column}; } var config = this.config; this.config = []; if(typeof colIndex == 'number'){ config.splice(colIndex, 0, column); }else{ colIndex = config.push(column); } this.setConfig(config); return colIndex; }, removeColumn: function(colIndex){ var config = this.config; this.config = [config[colIndex]]; config.splice(colIndex, 1); this.setConfig(config); } }); Ext.override(Ext.grid.GridPanel,{ addColumn: function(field, column, colIndex){ if(!column){ if(field.dataIndex){ column = field; field = field.dataIndex; } else{ column = field.name || field; } } this.store.addField(field); return this.colModel.addColumn(column, colIndex); }, removeColumn: function(name, colIndex){ this.store.removeField(name); if(typeof colIndex != 'number'){ colIndex = this.colModel.findColumnIndex(name); } if(colIndex >= 0){ this.colModel.removeColumn(colIndex); } } });
var header = new Ext.ux.plugins.GroupHeaderGrid({
rows: [
[
{},
{header : }
]
]
});
i wan to ask how i can filled header to get from json..
thanks
-
20 Dec 2010 2:32 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
Why are you using removeColumn and addColumn for this? This is really inefficient when doing multiple columns.
You should:
- Assign a new columngroup rows array to grid.getColumnModel().rows
- Assign the new columns with grid.getColumnModel().setConfig(newColumns)
ps. Why are you using Ext.ux.plugins.GroupHeaderGrid? Are you still on Ext 3.0 or older?
-
28 Dec 2010 6:09 PM #3
thanks for your reply..
how i can used grid.getColoumnModel.rows() in my code
can you give example how to use grid.getColoumnModel.rows
i used ext 2.3..
thanks.
-
28 Dec 2010 10:47 PM #4
i dont know how to use grid.getColumnModel().rows but i try used groupColumnHeader plugin..
and display error
this is my code to get header from database from ajax request
and this is function generateConfig()Code:function apply() { Ext.Ajax.request({ url: baseHref + newhid.fluid_consumption_analysis.controller + '/get_header', params: this.getForm().getValues(), scope: this, success: function(resp, options) { resp = Ext.decode(resp.responseText); countTab = resp.length; var colHeader = new Array(); for (i=0;i<countTab;i++) { colCount = resp[i].colHeader.length; Ext.getCmp('cpt_grid').destroy(); var grid = new newhid.fluid_consumption_analysis.grid(); grid.render('fluid_analysis'); for(c=0;c<colCount;c++) { // get Header(array) --- comp_mod = resp[i].colHeader[c].header; arr = resp[i].colHeader[c].header; storex = (Array({'name':resp[i].colHeader[c].header})); generateConfig(); } } } });
Code:function generateConfig(){ var arr, colspan_header = [['Cum Usage'],['Fluid Rate'],['Cycle']] Ext.iterate(comp_mod, function(colspan_header){ continentGroupRow.push({ header: comp_mod, align: 'center', colspan: colspan_header }); }) }
andCode:var header = new Ext.ux.grid.ColumnHeaderGroup({ rows: [comp_mod] });
-
28 Dec 2010 10:49 PM #5
i dont know how to use grid.getColoumnModel.rows
i try to used groupColoumnHeader
and displaying error..
Ext.iterate is not function
-
28 Dec 2010 11:47 PM #6Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
Ext.iterate was added in Ext 3 to iterate over arrays or objects, but because it's used here for arrays only, you can replace it with Ext.each.
-
29 Dec 2010 12:10 AM #7
-
29 Dec 2010 12:26 AM #8
-
29 Dec 2010 12:50 AM #9
-
29 Dec 2010 12:52 AM #10Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
OK, and what kind of JSON data is your server returning.
Similar Threads
-
Build GroupHeader based on values from server (GroupHeaderGrid)
By phpfreak in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 15 Jul 2010, 11:54 PM -
How to init groupHeader plugin after reconfigure gridpanel
By wguo in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 5 Apr 2010, 5:29 PM -
GroupHeader of a GroupingView with no rows
By gogofe in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 22 Jul 2009, 5:09 AM -
Grid groupheader
By nukboon in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 24 Jun 2009, 4:10 AM -
GroupHeader Plugin Query
By varsha.kothari in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 13 Apr 2009, 3:50 AM


Reply With Quote