开发者

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.


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';
        }
    }


What you need to do is implement a nested grid using the expander plugin. On the click or expand event, you can use your row's ID as a key to load the sub-rows.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜