访问 Extjs4 中的标头容器

发布于 2025-01-01 12:46:54 字数 355 浏览 2 评论 0原文

我想调用标头容器的 getGridColumns() 方法,但我无法访问网格的标头容器。我尝试了以下方法:

initComponent : function() {
            var grid = this;

    var headerCt = grid.getView.getHeaderCt(); //here
    var menuItems = new Array();
    menuItems = headerCt.getGridColumns(true);
               ...
}

但这不起作用。它给我错误“对象不支持此属性或方法”。有什么建议吗?

I want to call the getGridColumns() method of the header container but I am not getting access to the grid's header container. I tried the following:

initComponent : function() {
            var grid = this;

    var headerCt = grid.getView.getHeaderCt(); //here
    var menuItems = new Array();
    menuItems = headerCt.getGridColumns(true);
               ...
}

but this is not working. It gives me error as 'Object doesn't support this property or method'. Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡忘如思 2025-01-08 12:46:54

通过在定义网格列时设置侦听器(通过传入对象而不是仅传入数组),我已经能够满足访问网格标头容器的大部分需求。然后,在 columns 对象的项目中设置列数组。
示例:

Ext.create('Ext.grid.Panel', {
  ...,
  columns : {
    listeners : {
      boxready : function(headerCt) {
        console.log(headerCt);
      }
    },
    items : []
  },
  ...
});

获得 headerCt 后,您就可以调用 getGridColumns()getVisibleGridColumns()
希望这有帮助。

I've been able to satisfy most of my needs to access a grids header container by setting listeners when defining the columns of the grid (by passing in an object instead of just an array). Then, set your array of columns in the items of the columns object.
Example:

Ext.create('Ext.grid.Panel', {
  ...,
  columns : {
    listeners : {
      boxready : function(headerCt) {
        console.log(headerCt);
      }
    },
    items : []
  },
  ...
});

Once you have the headerCt then you can call getGridColumns() or getVisibleGridColumns().
Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文