2017-10-04 78 views
1

所以我有一個常用的網格,一些列:ExtJS的GridPanel中與單選按鈕的列

    { 
         xtype   : 'gridpanel', 
         mode   : "MULTI", 
         region   : 'center', 
         title   : "grid", 
         id    : 'datagridResult', 
         margin   : '10 5 5 5', 

        columns : [ 
           { 
            xtype : 'gridcolumn', 
            dataIndex: 'TEST', 
            flex  : 0.25 
           }, 
           { 
            xtype : 'gridcolumn', 
            dataIndex: 'Test2' 
            flex  : 2 
           }, 
           //... 

我要的是增加3個列,其是單選按鈕(每列一個按鈕)。我試過這樣的:

       { 
            xtype : 'gridcolumn', 
            text  : "FOR" 
            dataIndex: 'for', 
            flex  : 1, 
            editor: { 
             xtype  : 'radiofield', 
             name  : 'Regex', 
             inputValue: 'Checked' 
            }, 
           } 

而且它不起作用。所以我在這裏要求任何建議。

回答

1

而且它不起作用。所以我在這裏要求任何sugestions

在ExtJS有xtype:'widgetcolumn'。 窗口小部件列配置了窗口小部件配置對象,該對象指定xtype以指示此列的單元格中的窗口小部件或組件屬於哪種類型。

我已經創建了一個Sencha Fiddle演示。它會顯示如何工作。希望這會幫助你。

Ext.create('Ext.data.Store', { 
    storeId: 'simpsonsStore', 
    fields: ['name', 'email', 'phone', { 
     name: 'checked', 
     type: 'boolean', 
     defaultValue: true 
    }], 
    data: [{ 
     name: 'Lisa', 
     email: '[email protected]', 
     phone: '555-111-1224' 
    }, { 
     name: 'Bart', 
     email: '[email protected]', 
     phone: '555-222-1234' 
    }, { 
     name: 'Homer', 
     email: '[email protected]', 
     phone: '555-222-1244' 
    }, { 
     name: 'Marge', 
     email: '[email protected]', 
     phone: '555-222-1254' 
    }] 
}); 

Ext.create('Ext.grid.Panel', { 
    title: 'Simpsons', 
    store: Ext.data.StoreManager.lookup('simpsonsStore'), 
    columns: [{ 
     text: 'Name', 
     dataIndex: 'name' 
    }, { 
     text: 'Email', 
     dataIndex: 'email', 
     flex: 1 
    }, { 
     text: 'Phone', 
     dataIndex: 'phone' 
    }, { 
     text: 'Status', 
     width: 150, 
     xtype: 'widgetcolumn', 
     dataIndex: 'checked', 
     onWidgetAttach: function (column, widget, record) { 
      widget.down(`[inputValue=${record.get('checked')}]`).setValue(true); 
     }, 
     widget: { 
      xtype: 'radiogroup', 
      items: [{ 
       boxLabel: 'Yes', 
       inputValue: true 
      }, { 
       boxLabel: 'No', 
       inputValue: false 
      }] 
     } 
    }], 
    height: 200, 
    width: 400, 
    renderTo: Ext.getBody() 
}); 
+0

謝謝,謹慎的我想要的 – Chazz1

+0

非常歡迎☺ –