1

主题。

就我而言,我可以删除所有复选框 - 这是错误的。它应该像 Sencha GXT CheckBox Grid:http: //i.stack.imgur.com/rhRCr.png

描述: 1)数据网格被渲染 2)点击排序菜单,选择“列” 3)以任何顺序隐藏一些列(例如 5 个中的 4 个) 4)最后一个菜单项应该像屏幕截图一样变为非活动状态。

最后一个 - 我的意思是它不是 id = (colCount - 1) 的项目。

4

1 回答 1

1

GridView负责处理标题菜单,这包括菜单。但是 GridView 没有您要求的行为。

要完成此行为,您应该实现它。

正如我上面提到的,由视图控制的菜单,如果你检查文档和源代码,你会注意到视图有一个名为 colMenu 的属性,它指向列显示/隐藏菜单。你可以监听它的事件来实现行为。

这里我是如何完成这种行为的:

...
// we need to wait until the grid is rendered, because colMenu doesn't exist
// until the grid and its view is rendered.
grid.on( 'afterrender', function() {

    this.view.colMenu.on( 'itemclick', function( item, e ){

        // active will contain visible columns
        var active = [], i;

        // iterate through all menu items to find checked ones
        for ( i = 0; i < this.items.items.length, i++ ) {
            if ( this.items.items[ i ].checked ) active.push( this.items.items[ i ] );
        };

        // if there is only one active one, disable it
        if ( active.length == 1 ) {
            active[ 0 ].disable();

        // if there is more then one, enable the disabled ones
        } else if ( active.length > 0 ) {
            for( i = 0; i < active.length; i++ ) {
                if ( active[ i ].disabled ) active[ i ].enable();
            }
        }

    // buffer is important for our itemclick event listener.
    // it'll wait 100ms after default itemclick event to finish its job.
    }, this.view.colMenu, { buffer : 100 } );
} );
于 2012-07-12T14:54:43.700 回答