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 } );
} );