1
我已經瀏覽了同一個問題的前幾篇文章,但都沒有解決我的問題。 我有一個隱藏的特定列的網格面板。當組合框選擇更改時,我需要顯示該列。如何在extjs 3.4網格面板中顯示/隱藏列
這裏是我的代碼
Store1 = new Ext.data.JsonStore({
url: 'url',
root: 'rows',
autoLoad: true,
fields: ['field1', 'field2']
});
Grid1 =
{
xtype: 'grid',
id: 'grid1',
autoHeight: true,
autoWidth: true,
autoScroll: true,
border: false,
trackMouseOver: false,
frame: true,
store: Store1,
columns: [
{ header: 'Col1', dataIndex: 'field1'},
{ header: 'Col2', dataIndex: 'field2',
renderer: function (value, metaData, record, rowIndex, colIndex, store) {
if (isShow==true) {
value = 100;
}
else {
hideCols(Ext.getCmp('grid1'));
}
return value;
}}
]};
xtype: 'combo',
store: comboStore,
fieldLabel: 'title',
displayField: 'title',
valueField: 'title',
typeAhead: false,
editable: false,
allowBlank: false,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
name: 'combo1',
selectOnFocus: true
, onSelect: function (cmb) {
isShow = true;
showCols(Ext.getCmp('grid1'));
}
// methods
hideCols = function (grid) {
grid.getColumnModel().setHidden(grid.getColumnModel().findColumnIndex('filed2'), true);
};
showCols = function (grid) { grid.getColumnModel().setHidden(grid.getColumnModel().findColumnIndex('filed2'), false);
};
我在哪裏出了錯?