[英]ExtJs4 - What is the equivalent to the grid ColumnModel?
What is the equivalent to the ExtJs3 Ext.grid.ColumnModel
in ExtJs4? 与ExtJs4中的ExtJs3 Ext.grid.ColumnModel
相同的是什么?
What I want to do is hide a column, I did something like below in ExtJs3: 我想要做的是隐藏一个列,我在ExtJs3中做了类似下面的事情:
grid.colModel.setHidden(1, true);
您可以使用Ext.grid.column.Column的setVisible方法隐藏/显示列:
grid.columns[1].setVisible(false);
The other answers can be problematic if your column indexes change. 如果列索引发生更改,其他答案可能会有问题。
Here is another solution: 这是另一个解决方案:
Set itemId on the column definition: 在列定义上设置itemId:
{
itemId: 'myActionColumn',
xtype: 'actioncolumn',
width: 50,
items: [ ...
}
Then to hide: 然后隐藏:
grid.down('#myActionColumn').hide();
Ext.grid.header.Container Ext.grid.header.Container
code of Ext.panel.Table: Ext.panel.Table的代码:
headerCtCfg = me.columns || me.colModel,
...
if (headerCtCfg instanceof Ext.grid.header.Container) {
me.headerCt = headerCtCfg;
me.headerCt.border = border;
me.columns = me.headerCt.items.items;
}
so u can use 所以你可以使用
grid.columns[i].hide()/show()
Another solution more flexible : 另一个解决方案更灵活
grid.down("[dataIndex="+di+"]").setVisible(v);
You can change dataIndex
for another property like name
or whatever. 您可以为name
或其他任何属性更改dataIndex
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.