簡體   English   中英

Extjs ComboBox里面的網格

[英]Extjs ComboBox inside grid

我有一個帶有一些數據的網格(用戶列表)。 對於每一行,我有許多操作,例如更新,刪除,激活,暫停,查看您為其命名的訂單。

我沒有放置那么多可以填充400-500像素的按鈕,而是放置一個組合框,每個區域都應用一個動作。

問題是我不能簡單地在列行中渲染一個組合框,或者我錯過了什么? 有人可以對此有所了解嗎?

new Ext.grid.GridPanel({
    region: 'center',
    id: 'usersGrid',
    store: store,
    stripeRows: true,
    autoExpandColumn: 'username',
    columns: [{
            // username
        },{
            // email
        },{
            // last seen
        },{
            //  actions combo, it won't show
            header: '',
            width: 220,
            fixed: true,
            hideable: false,
            dataIndex: 'actions',
            renderer: new Ext.form.ComboBox({
                store: new Ext.data.SimpleStore({
                    id: 0,
                    fields: ['abbr', 'action'],
                    data: [
                        ['suspend', 'Suspend'],
                        ['activate', 'Activate'],
                        ['update', 'Update'],
                        ['delete', 'Delete']
                    ]
                }),
                displayField: 'action',
                valueField: 'abbr',
                mode: 'local',
                typeAhead: false,
                triggerAction: 'all',
                lazyRender: true,
                emptyText: 'Select action'
            })
        }
    ]
});
  1. 將網格轉換為可編輯網格
  2. 在列中添加編輯器配置而不是“渲染器”。 在下面找到更改的代碼。
new Ext.grid.EditorGridPanel({
    region: 'center',
    id: 'usersGrid',
    store: store,
    stripeRows: true,
    autoExpandColumn: 'username',
    columns: [{
        // username
    }, {
        // email
    }, {
        // last seen
    }, {
        //  actions combo, it won't show
        header: '',
        width: 220,
        fixed: true,
        hideable: false,
        dataIndex: 'actions',
        editor: {
            xtype: 'combo',
            store: new Ext.data.ArrayStore({
                fields: ['abbr', 'action'],
                data: [
                    ['suspend', 'Suspend'],
                    ['activate', 'Activate'],
                    ['update', 'Update'],
                    ['delete', 'Delete']
                ]
            }),
            displayField: 'action',
            valueField: 'abbr',
            mode: 'local',
            typeAhead: false,
            triggerAction: 'all',
            lazyRender: true,
            emptyText: 'Select action'
        }
    }]
});

你試圖完成這一點大多是正確的。 您添加自定義編輯器的方式可能需要一些調整..您是否嘗試過此更改?

editor: new Ext.form.ComboBox({
                    store: new Ext.data.SimpleStore({
                        id: 0,

遺憾的是,我無法確定您的代碼在做什么而且無法正常工作。

您使用的是什么版本的ExtJS? 有一點值得注意的是,我發現在當前的ExtJS API文檔中我沒有看到任何名為Ext.data.SimpleStore的對象。 您是否嘗試過使用其他類型的數據存儲? 您可能想嘗試為此組合使用不同類型的商店?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM