1

件名

私の場合、すべてのチェック ボックスを削除できますが、これは間違っています。これは、Sencha GXT CheckBox Grid のようになるはずです: http://i.stack.imgur.com/rhRCr.png

説明: 1) Datagrid がレンダリングされます 2) 並べ替えメニューをクリックし、[列] を選択します 3) いくつかの列を任意の順序で非表示にします (たとえば、4/5) 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 に答える