[HTML]View Plain copy print?
- Gridpanel row spanning (well, sort of ...)
- the current Gridpanel implementation doesn ' t support row spanning, because the rows aren ' t part of the same table.
- The only thing your can do are make the grid look like it have row spanning by changing the CSS.
- Example:
- Code:
- < style type="text/css">
- . Grid-row-span. x-grid3-row {
- border-bottom:0;
- }
- . Grid-row-span. x-grid3-col {
- border-bottom:1px solid #ededed;
- }
- . Grid-row-span. Row-span {
- border-bottom:1px solid #fff;
- }
- . Grid-row-span. Row-span-first {
- position:relative;
- }
- . Grid-row-span. Row-span-first. X-grid3-cell-inner {
- Position:absolute;
- }
- . Grid-row-span. row-span-last {
- border-bottom:1px solid #ededed;
- }
- </style >
- < script type="text/javascript">
- Ext.onready (function () {
- New Ext.viewport ({
- layout: ' Fit ',
- items: {
- xtype: ' Grid ',
- store:new Ext.data.ArrayStore ({
- Fields : [
- {name: ' Company '},
- {name: ' Price ', type: ' Float '},
- {name: ' Change ', type: ' Float '},
- {name: ' Pctchange ', type: ' Float '},
- {name: ' Lastchange ', type: ' Date ', DateFormat: ' n/j h:ia '},
- {name: ' Industry '}
- ],
- data: [
- [' 3m Co ', 71.72,0.02,0.03, ' 4/2 12:00am ', ' manufacturing '],
- [' Alcoa Inc ', 29.01,0.42,1.47, ' 4/1 12:00am ', ' manufacturing '],
- [' Altria Group Inc ', 83.81,0.28,0.34, ' 4/3 12:00am ', ' manufacturing '],
- [' American Express company ', 52.55,0.01,0.02, ' 4/8 12:00am ', ' Finance '],
- [' American International Group, Inc. ', 64.13,0.31,0.49, ' 4/1 12:00am ', ' Services ',
- [' t Inc ', 31.61,-0.48,-1.54, ' 4/8 12:00am ', ' Services '],
- [' Boeing Co. ', 75.43,0.53,0.71, ' 4/8 12:00am ', ' manufacturing '],
- [' Caterpillar Inc. ', 67.27,0.92,1.39, ' 4/1 12:00am ', ' Services '],
- [' Citigroup, Inc. ', 49.37,0.02,0.04, ' 4/4 12:00am ', ' Finance '],
- [' e.i du Pont de Nemours and Company ', 40.48,0.51,1.28, ' 4/1 12:00am ', ' manufacturing '],
- [' Exxon Mobil Corp ', 68.1,-0.43,-0.64, ' 4/3 12:00am ', ' manufacturing '],
- [' General Electric Company ', 34.14,-0.08,-0.23, ' 4/3 12:00am ', ' manufacturing '],
- [' General Motors Corporation ', 30.27,1.09,3.74, ' 4/3 12:00am ', ' Automotive '],
- [' Hewlett-Packard Co. ', 36.53,-0.03,-0.08, ' 4/3 12:00am ', ' computer '],
- [' Honeywell Intl Inc ', 38.77,0.05,0.13, ' 4/3 12:00am ', ' manufacturing '],
- [' Intel Corporation ', 19.88,0.31,1.58, ' 4/2 12:00am ', ' computer '],
- [' International Business Machines ', 81.41,0.44,0.54, ' 4/1 12:00am ', ' computer '],
- [' Johnson & Johnson ', 64.72,0.06,0.09, ' 4/2 12:00am ', ' Medical '],
- [' JP Morgan & Chase & Co ', 45.73,0.07,0.15, ' 4/2 12:00am ', ' Finance '],
- [' mcdonald\ ' s Corporation ', 36.76,0.86,2.40, ' 4/2 12:00am ', ' food '],
- [' Merck & Co., Inc. ', 40.96,0.41,1.01, ' 4/2 12:00am ', ' Medical '],
- [' Microsoft Corporation ', 25.84,0.14,0.54, ' 4/2 12:00am ', ' computer '],
- [' Pfizer Inc ', 27.96,0.4,1.45, ' 4/8 12:00am ', ' Services ', ' Medical '],
- [' The Coca-Cola Company ', 45.07,0.26,0.58, ' 4/1 12:00am ', ' food '],
- [' The Home Depot, Inc. ', 34.64,0.35,1.02, ' 4/8 12:00am ', ' Retail '],
- [' The Procter & Gamble company ', 61.91,0.01,0.02, ' 4/1 12:00am ', ' manufacturing '],
- [' Technologies Corporation ', 63.26,0.55,0.88, ' 4/1 12:00am ', ' computer '],
- [' Verizon Communications ', 35.57,0.39,1.11, ' 4/3 12:00am ', ' Services '],
- [' Wal-mart Stores, Inc. ', 45.45,0.73,1.63, ' 4/3 12:00am ', ' Retail ',
- [' Walt Disney Company (Holding Company) ', 29.89,0.24,0.81, ' 4/1 12:00am ', ' Services ']
- ],
- Sortinfo: {
- field: ' Industry ',
- direction: ' ASC '
- }
- }),
- cls: ' Grid-row-span ',
- columns: [
- {header: "Industry", width:200, Sortable:true, renderer:function (value, meta, record, RowIndex, Colindex, store) {
- var First =!rowindex | | value!== store.getat (rowIndex-1). Get (' industry '),
- Last = rowIndex > = Store.getcount ()-1 | | value!== store . getAt (RowIndex + 1). Get (' industry ');
- meta.css + = ' Row-span ' + (first? ' Row-span-first ': ') + (last? ' Row-span-last ': ');
- if (first) {
- var I = RowIndex + 1;
- While (i < store.getcount() && value = = = Store.getat (i). Get (' industry ')) {
- i++;
- }
- var RowHeight = - , padding = 6 ,
- height = (RowHeight * (i-rowindex)-padding) + ' px ';
- meta.attr = ' style= ' height: ' + height + '; line-height: ' + height + '; ';
- }
- return first? Value: ';
- }, Dataindex: ' Industry '},
- {header: "Company", width:300, Sortable:true, Dataindex: ' Company '},
- {header: "Price", width:100, Sortable:true, Renderer:Ext.util.Format.usMoney, dataindex: ' Price '},
- {header: "Change", width:100, Sortable:true, dataindex: ' Change ', Renderer:Ext.util.Format.usMoney},
- {header: "Last Updated", width:100, Sortable:true, Renderer:Ext.util.Format.dateRenderer (' m/d/y '), Dataindex: ' Lastchange '}
- ],
- columnlines:true
- }
- });
- });
- </script >
Gridpanel row spanning (well, sort of ...) The current Gridpanel implementation doesn ' t support row spanning, because the rows aren ' t part of the same table. The only thing your can do are make the grid look like it have row spanning by changing the CSS. Example:code:<style type= "Text/css" >.grid-row-span. X-grid3-row {border-bottom:0;}. Grid-row-span. x-grid3-col {border-bottom:1px solid #ededed;}. Grid-row-span. row-span {border-bottom:1px solid #fff;}. Grid-row-span. Row-span-first {position:relative;}. Grid-row-span. Row-span-first. x-grid3-cell-inner {position:absolute;}. Grid-row-span. row-span-last {border-bottom:1px solid #ededed;} </style><script type= "Text/javascript" >ext.onready (function () {new Ext.viewport ({layout: ' fit ', Items: {xtype: ' grid ', Store:new Ext.data.ArrayStore ({fields: [ {name: ' company '}, {name: ' Price ', type: ' Float '}, {name: ' Change ', type: ' float '}, {name: ' Pctchange ', type: ' Float '}, {name: ' Lastchange ', type: ' Date ', DateFormat: ' n/j H:ia '}, {name: ' Industry '}], Data: [[' 3m Co ', 71.72,0.02,0.03, ' 4/2 12:00am ', ' manufacturing '], [' Alco A Inc ', 29.01,0.42,1.47, ' 4/1 12:00am ', ' manufacturing ', [' Altria Group Inc ', 83.81,0.28,0.34, ' 4/3 12:00a M ', ' manufacturing '], [' American Express company ', 52.55,0.01,0.02, ' 4/8 12:00am ', ' Finance '], [' American International Group, Inc. ', 64.13,0.31,0.49, ' 4/1 12:00am ', ' Services '], [' t I NC. ', 31.61,-0.48,-1.54, ' 4/8 12:00am ', ' Services ', [' Boeing Co. ', 75.43,0.53,0.71, ' 4/8 12:00am ', ' manufa Cturing '], [' Caterpillar Inc ', 67.27,0.92,1.39, ' 4/1 12:00am ', ' Services '], [' Citigro Up, Inc. ', 49.37,0.02,0.04, ' 4/4 12:00am ', ' Finance '], [' e.i. du Pont de Nemours and Company ', 40.48,0.51,1.28, ' 4/1 12:00am ', ' Man Ufacturing '], [' Exxon Mobil Corp ', 68.1,-0.43,-0.64, ' 4/3 12:00am ', ' manufacturing '], [' General Electric Company ', 34.14,-0.08,-0.23, ' 4/3 12:00am ', ' manufacturing '], [' General Motors Corpora tion ', 30.27,1.09,3.74, ' 4/3 12:00am ', ' Automotive '], [' Hewlett-Packard Co. ', 36.53,-0.03,-0.08, ' 4/3 12:00 Am ', ' computer '], [' Honeywell Intl Inc ', 38.77,0.05,0.13, ' 4/3 12:00am ', ' manufacturing '], [' Intel Corporation ', 19.88,0.31,1.58, ' 4/2 12:00am ', ' computer '], [' International Business Machines ', 81.41,0.44,0.54, ' 4/1 12:00am ', ' computer '], [' Johnson & Johnson ', 64.72,0.06,0.09, ' 4/2 12:00am ', ' Medical '], [' JP Morgan & Chase & Co ', 45.73,0.07,0.15, ' 4/2 12:00am ', ' Finance '], [' mcdonald\ ' s CorporAtion ', 36.76,0.86,2.40, ' 4/2 12:00am ', ' food '], [' Merck & Co., Inc. ', 40.96,0.41,1.01, ' 4/2 12:00am ', ' Medical ', [' Microsoft Corporation ', 25.84,0.14,0.54, ' 4/2 12:00am ', ' computer '], [' P Fizer Inc ', 27.96,0.4,1.45, ' 4/8 12:00am ', ' Services ', ' Medical '], [' The Coca-Cola Company ', 45.07,0.26,0. [' 4/1 12:00am ', ' food '], [' The Home Depot, Inc. ', 34.64,0.35,1.02, ' 4/8 12:00am ', ' Retail '], [' The Procter & Gamble company ', 61.91,0.01,0.02, ' 4/1 12:00am ', ' manufacturing '], [' The Technologies Corporation ', 63.26,0.55,0.88, ' 4/1 12:00am ', ' computer '], [' Verizon Communications ', 35.57,0 .39,1.11, ' 4/3 12:00am ', ' Services ', [' Wal-mart Stores, Inc. ', 45.45,0.73,1.63, ' 4/3 12:00am ', ' Retail '], [' Walt Disney Company (Holding Company) ', 29.89,0.24,0.81, ' 4/1 12:00am ', ' Services '] ], the SorTinfo: {field: ' Industry ', direction: ' ASC '}}), CLS: ' Grid-row-span ', columns: [{header: ' Industry ', width:200, Sortable:true, renderer: function (value, meta, record, RowIndex, Colindex, store) {var first =!rowindex | | value!== store.g EtAt (rowIndex-1). Get (' industry '), last = RowIndex >= store.getcount ()-1 | | Value!== store.getat (RowIndex + 1). Get (' industry '); Meta.css + = ' Row-span ' + (first? ' Row-span-first ': ') + (last? ' Row-span-last ': '); if (first) {var i = RowIndex + 1; while (I < Store.getcount () && value = = = Store.getat (i). Get (' industry ')) {i++; } var = rowHeight, padding = 6, height = (Rowheig HT * (I-ROWINDEX)- padding) + ' px '; meta.attr = ' style= ' height: ' + height + '; line-height: ' + height + '; ';} Return first? Value: "; }, Dataindex: ' Industry '}, {header: "Company", width:300, Sortable:true, Dataindex: ' Company '}, {header: "Price", width:100, Sortable:true, Renderer:Ext.util.Format.usMoney, dataindex: ' Price '}, {header: "Change", width:100, Sortable:true, dataindex: ' Change ', Renderer:Ext.util.Format.usMoney}, {h Eader: "Last Updated", width:100, Sortable:true, Renderer:Ext.util.Format.dateRenderer (' m/d/y '), Dataindex: ' Lastchange '}], columnlines:true}}); </script>
In the report often there is a need for a dimension or more than one dimension of the same value display only once and consolidated requirements, ExtJS grid default does not take such a function, we need to be implemented by ourselves, on its official web site someone gave the following solution, Although there are some flaws (not centered display), but still can barely realize the function, see the code implementation found that he is a column value of a column of values to merge, if you want to merge a few columns the same value is powerless, think about the decision to take a workaround: The number of columns to be merged as a key value, for the same key value of the So there is the following implementation, of course, there is still no way to center
{header: "date", width:100, Sortable:true, renderer:function (value, meta, record, RowIndex, Colindex, store) {
if (rowindex>0) {
Return Store.getat (rowIndex-1). Get (' key ')!=store.getat (RowIndex). Get (' key ')? Value: ";
}else{
return value;
}
}, Dataindex: ' Publishdate '
/////////////////////////////