Javascript 隐藏 ExtJS 网格列标题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2011380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hiding ExtJS Grid Column header
提问by Madhu
I understand I can hide grid column header using the code.
我知道我可以使用代码隐藏网格列标题。
#gridid .x-grid3-hd-row { display:none; }
But I don't want to use any CSS change. How to do the same using JavaScript?
但我不想使用任何 CSS 更改。如何使用 JavaScript 做同样的事情?
回答by Aragon
you can do it easily with adding this to Ext.grid.GridPanelto this way :
您可以通过将其添加到Ext.grid.GridPanel以这种方式轻松完成:
hideHeaders: true
回答by Jan Fabry
You can set the hideHeadersconfiguration option of the GridPanelto true. Or do you mean after the grid is rendered?
您可以将 的hideHeaders配置选项GridPanel设置为true。或者你的意思是在网格渲染之后?
Edited:If you want to change (or disable) the way the header is created, you could also override renderHeadersor updateHeadersfrom GridView. Another way might be to pass a templatesoption to the GridView, with the headervalue set to an empty template instead of the default:
编辑:如果您想更改(或禁用)标题的创建方式,您还可以覆盖renderHeaders或updateHeadersfrom GridView。另一种方法可能是将templates选项传递给GridView,并将header值设置为空模板而不是默认值:
ts.header = new Ext.Template(
'',
'{cells}',
'
'
);
Although the default implementation writes the header in this.innerHd, and innerHdis defined as this.mainHd.dom.firstChild, and this.mainHdis set to hidden if if hideHeadersoption is set. So I would expect that option would affect the column headers too.
尽管默认实现将标头写入this.innerHd, 并innerHd定义为this.mainHd.dom.firstChild,this.mainHd如果设置了hideHeaders选项,则设置为隐藏。所以我希望该选项也会影响列标题。
Edited:What version of ExtJS are we talking about? I looked at the current source, which is 3.1 I guess.
编辑:我们在谈论什么版本的 ExtJS?我查看了当前的 source,我猜是 3.1 。
回答by Sushith
just add hideHeaders: trueto your grid. it should work
只需添加hideHeaders: true到您的网格。它应该工作
回答by Mark
You can add this to your grid definition:
您可以将其添加到您的网格定义中:
listeners: {
render: function(grid) {
grid.getView().el.select('.x-grid3-header').setStyle('display', 'none');
}
},
回答by gideon
Usually you end up wanting this when you put your grid into a panel.
通常,当您将网格放入面板时,您最终会想要这个。
For me the css hacks seemed bad and only this worked:
对我来说,css hacks 看起来很糟糕,只有这样有效:
preventHeaders: true
See the property here in the docs.

