Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJS Grid Panel - Multiple "rows" per row?

We have an ExtJS Grid Panel that has grown to include too many columns (imo), so I am looking into enfolding some data into "sub-rows" of the main row. Like:

Data1 | Data2 | Data3 | Data4 | Data5
  Some additional data that spans
Data1 | Data2 | Data3 | Data4 | Data5
  Some additional data that spans

I am aware of the expander plugin, but we wouldn't need the expand/collapse functionality and always need the sub-rows open.

Any thoughts or ideas?

Thanks in advance.

like image 1000
Chewpers Avatar asked May 23 '11 19:05

Chewpers


1 Answers

If you're using ExtJS-4,

// ...
var rowBodyFeature = Ext.create('Ext.grid.feature.RowBody', {
    getAdditionalData: function(data, rowIndex, record, orig) {
        var headerCt = this.view.headerCt,
        colspan  = headerCt.getColumnCount();
        return {
            rowBody: "HELLO WORLD!", // do something with record
            rowBodyCls: this.rowBodyCls,
            rowBodyColspan: colspan
        };
    }
});

Ext.create('Ext.grid.Panel', {
    // ...
    features: [rowBodyFeature]
    // ...
});

If using ExtJS-3, try:

new Ext.grid.GridPanel({
    //...
    viewConfig: {
        enableRowBody: true,
        getRowClass: function(record, rowIndex, p, store) {
            p.body = 'HELLOW WORLD: ' + record.get('attribute');
            return 'x-grid3-row-expanded';
        }
    }
like image 64
Dzhu Avatar answered Nov 03 '22 20:11

Dzhu