[ExtJS5學習筆記]第二十三節 Extjs5中表格gridpanel的列格式設定
------------------------------------------------------------------------------------------------------------------------------------
在使用表格的時候,我們預設都是載入一些文本文字,可是偶爾我們還有個人化的需求,比如我想增加一個選擇框,或者我需要一個日期的輸入。那麼這時候,就需要配置gridpanel的格式屬性了。
配置的時候遇到了這個錯誤:TypeError: headers[i].getCellWidth is not a function
我配置的代碼如下
Ext.create('Ext.grid.Panel', { frame: true, columnLines: true, // 加上表格線 selType: 'cellmodel', dockedItems: [{ xtype: 'toolbar', dock: 'top', items: [{ xtype: 'label', text: '使用日期:', //glyph: 0xf016, //handler: 'addRecord', },{ xtype: 'datefield', name: 'dateuse', format: 'Y-m-d', submitFormat: 'Y-m-d' },{ text: '查看此段', listeners: { click: function() { alert('I was clicked!'); }, } }] }],renderTo: Ext.getBody(), columns: [ { text: '車輛', dataIndex: '車輛' }, { text: '選擇', dataIndex: '選擇', xtype: 'checkbox'},//這個地方想配置選擇框 { text: '星期一', dataIndex: '星期一' }, { text: '星期二', dataIndex: '星期二' }, { text: '星期三', dataIndex: '星期三' }, { text: '星期四', dataIndex: '星期四' }, { text: '星期五', dataIndex: '星期五' }, { text: '星期六', dataIndex: '星期六' }, { text: '星期日', dataIndex: '星期日' } ],store: clxxStore}).show();
在配置選擇框的地方我配置的xtype為checkbox就出錯了。原因是對於gridpanel中的這個屬性,有單獨的組件配置:
所以想配置check的話就需要找到這個的別名chekcolunm
Ok.就這樣解決問題了。