2017-08-01 98 views
1

我正在使用Ext Js v6.2,在我用ext js grid構建的應用程序表中,我想添加組合框到特定單元格[DEMO IMAGE ATTACHED],當我嘗試將組合框的整個單元格更改添加到組合框時,但我需要特定的單元格來組合框。在這裏,我的代碼,我在文檔和其他東西中搜索它並沒有幫助,請解決問題。Ext Js如何將組合框添加到網格中的特定單元格?

 Ext.define('OtherCharges1', { 
      extend: 'Ext.data.Model', 
      fields: [ 
       {name: 'name', mapping: 'name'}, 
       {name: 'age', mapping: 'age'}, 
       {name: 'marks', mapping: 'marks'}, 
       {name: 'rate', mapping: 'rate'} 
      ] 
     }); 
     var newData1 = [ 
      {name: "Freight"}, 
      {name: "Insurance" }, 
      {name: " Addl Chrg(High Sea)"}, 
      {name: "Revenue Deposit on"} 
     ] 
     var gridStore3 = Ext.create('Ext.data.Store', { 
      model: 'OtherCharges1', 
      data: newData1 
     }); 
     var otherStore1 = Ext.create('Ext.grid.Panel', { 
      cls: 'custom-grid', 
      id: 'OtherId', 
      store: gridStore3, 
      stripeRows: true, 
      width: '100%', 
      collapsible: false, 
      enableColumnMove: false, 
      columnLines: true, 
      sortableColumns: false, 
      enableColumnHide: false, 
      enableColumnResize: false, 
      enableRowHeightSync: true, 
      columns: 
        [ 
         { 
          header: "", 
          dataIndex: 'name', 
          flex: 1 

         }, 
         { 
          editor: { 
           xtype: 'textfield', 
           selectOnFocus: true 
          }, 
          dataIndex: '', 
          flex: .5, 
          sortable: true, 
          hideable: false, 
         }, 
         { 
          editor: { 
           xtype: 'textfield', 
           selectOnFocus: true 
          }, 
          dataIndex: 'age', 
          flex: .5, 
          sortable: true, 
          hideable: false, 
         }, 
         { 
          editor: { 
           xtype: 'textfield', 
           selectOnFocus: true 
          }, 
          dataIndex: 'marks', 
          flex: .5, 
          sortable: true, 
          hideable: false, 
         }, 
         { 
          editor: { 
           xtype: 'textfield', 
           selectOnFocus: true 
          }, 
          dataIndex: 'rate', 
          flex: .5, 
          sortable: true, 
          hideable: false, 
         }], 
      selType: 'cellmodel', 
      plugins: [ 
       Ext.create('Ext.grid.plugin.CellEditing', { 
        clicksToEdit: 1 
       })] 
     }); 

Ext Js Grid

+0

開始爲了澄清,你想成爲麥酒只編輯特定列中的某些單元格? –

+0

@EvanTrimboli已經可以編輯所有的單元格,我關心的是特定單元格具有組合框的變化。 –

+0

對,只有列中的一些單元格,不是所有的單元格? –

回答

1

啓用編輯的網格,你需要編輯beforeedit事件的特定細胞。創建驗證以確保您正在編輯所需的單元格。

在這種情況下,你只能在第1列和行編輯單元格1.

grid.on('beforeedit', function(editor, e) { 
    if (e.colIdx === 1 && e.rowIdx === 1) 
    { 
     return true; 
    } 
    else 
    { 
     return false; 
    } 
}); 

記住,ExtJS的電網爲0
See this example fidlle.

相關問題