4

在此处输入图像描述

是否可以在此菜单中添加一个项目以重命名列标题?

4

2 回答 2

2

The question seems kind of vague and I believe the image attached is throwing me off.

Customizing a grid header menu (Answer)..

See either answer.

My final product I have even customized my answer further:

initComponent: function () {
    this.callParent(arguments);

    this.headerCt.on('headerclick', function (header, column, event, html) {
        if (column.xtype == 'rownumberer') {
            return false;
        };

        header.showMenuBy(column.el.dom, column);
    }, this);

    this.headerCt.on('menucreate', function (header, column, event, html) {
        var menu = header.getMenu();

        this.createHeaderMenu(menu);
    }, this);
},

createHeaderMenu: function (menu) {
    menu.removeAll();

    // simulate header menu to be plain (menu is already created at this point)
    menu.addCls(Ext.baseCSSPrefix + 'menu-plain');
    menu.name = 'report_data_header_menu';

    menu.add({
        name: 'sort_asc',
        text: 'Sort Ascending'
    }, {
        name: 'sort_desc',
        text: 'Sort Descending'
    }, {
        name: 'remove_column',
        text: 'Remove'
    });
}
于 2012-07-26T01:40:00.047 回答
0

你应该能够做到。

在 Ext.grid.header.Container 对象的 'menucreate' 事件上添加一个侦听器。该委托将向您传递菜单的引用,然后您可以操作菜单。

例子

var gridHeader = gridPanelInstance.getView().headerCt; //return the Header Container 

gridHeader.on('menucreate', function(gridHeaderContainer, menu, option) {

    // do whatever you want with the menu here...  eg: add/remove/ edit menu item
});
于 2012-06-20T05:58:49.157 回答