代码之家  ›  专栏  ›  技术社区  ›  Madhu

隐藏ExtJS网格列标题

  •  10
  • Madhu  · 技术社区  · 16 年前

    我知道我可以使用代码隐藏网格列标题。

    #gridid .x-grid3-hd-row { display:none; }
    

    但我不想使用任何CSS更改。如何使用javascript实现同样的功能?

    5 回复  |  直到 11 年前
        1
  •  19
  •   ᄂ ᄀ    11 年前

    将此添加到 外部网格网格面板 这样:

    hideHeaders: true
    
        2
  •  10
  •   Jan Fabry    16 年前

    您可以设置 hideHeaders configuration option of the GridPanel 到 true .或者你的意思是在网格渲染之后?

    编辑: 如果要更改(或禁用)头的创建方式,还可以重写 renderHeaders 或 updateHeaders 从 GridView . 另一种方法可能是通过 templates 选择权 GRIDVIEW 与 header 值设置为空模板而不是默认值:

    ts.header = new Ext.Template(
        '',
        '{cells}',
        '
    '
    );
    

    尽管默认实现将头写入 this.innerHd 和 innerHd 定义为 this.mainHd.dom.firstChild 和 this.mainHd 如果是,则设置为隐藏 劫持者 选项设置。所以我希望该选项也会影响列标题。

    编辑: 我们讨论的是什么版本的extjs?我看着 the current source 我想是3.1。

        3
  •  6
  •   Marc Plano-Lesay Laurentiu Amitroaie    13 年前

    只要添加 hideHeaders: true 到你的网格。它应该工作

        4
  •  4
  •   Mark    15 年前

    可以将此添加到网格定义中:

    listeners: {
        render: function(grid) {
            grid.getView().el.select('.x-grid3-header').setStyle('display', 'none');
        }
    },
    
        5
  •  0
  •   gideon    13 年前

    通常,当你把网格放到一个面板中时,你最终会想要这个。

    对我来说,CSS黑客似乎很糟糕,只有这样才能奏效:

    preventHeaders: true
    

    查看属性 here in the docs.