ExtJS 5永久隐藏Ext JS网格列
我正在使用ExtJs 5 Grid。我有一个按钮,当我点击它时,年龄列将通过使用下面的行隐藏。
Ext.getCmp('grdSample').columnManager.columns[2].setVisible(false);
我使用听众 - beforecellclick只是为了获得点击列的索引。但是当我点击最后一列(最后一列=隐藏列旁边)时,它仍然显示列的原始索引。隐藏的列仍然在网格中获得位置。
在CSS中 - 如果我们使用visibility:hidden,它会隐藏组件或标签,但仍然占用网页空间,但如果使用display:none,它将隐藏以及它不会占用网页空间。
我想隐藏的列不应该占用当前点击列的索引空间。 (不使用CSS)。
任何人都可以帮我解决这个问题。
Ext.onReady(function() {
var studentStore = new Ext.data.JsonStore({
autoLoad: true,
pageSize: 10,
fields: ['Name', 'Age', 'Fee'],
data: {
items: [
{ "Name": 'Puneet', "Age": '25', "Fee": '1000' },
{ "Name": 'Ankit', "Age": '23', "Fee": '2000' },
{ "Name": 'Rahul', "Age": '24', "Fee": '3000' }
]
},
proxy: {
type: 'memory',
reader: {
type: 'json',
rootProperty: 'items'
}
}
});
var window = new Ext.Window({
id: 'grdWindow',
width: 400,
title: 'Grid Samples',
items: [
{
xtype: 'panel',
layout: 'fit',
renderTo: Ext.getBody(),
items: [
{
xtype: 'button',
text: 'hide age column',
handler: function() {
Ext.getCmp('grdSample').columnManager.columns[2].setVisible(false);
}
},
{
xtype: 'grid',
id: 'grdSample',
height: 300,
selModel: Ext.create('Ext.selection.CheckboxModel',
{
}),
store: studentStore,
columns: [
{
header: 'Name',
dataIndex: 'Name',
},
{
header: 'Age',
dataIndex: 'Age',
},
{
header: 'Fee',
dataIndex: 'Fee'
}
],
listeners:{
beforecellclick: function (el, td, cellIndex, record, tr, rowIndex, e, eOpts) {
debugger;
}
},
dockedItems:
[
{
xtype: 'pagingtoolbar',
store:studentStore,
dock:'bottom',
displayInfo:true
}
]
}
]
}
]
});
隐藏列后,当点击最后一列(费用)时,它返回索引2.它应该是1. –
为什么你需要点击列的索引? –
其实我只是需要正确的细胞指数。当我点击这个专栏时。基于点击的列数据索引,我有很多任务要实现。防爆。当我将得到正确的细胞索引,以便我可以得到正确的点击列的数据索引。基于数据索引,我想执行一些代码。如果你可以得到正确的点击列数据索引而不需要获取单元格索引,那么它会好很多。 –