Search code examples
javascriptextjsextjs4

How to change value of "disableSelection" of a grid in Ext js 4.0 dynamically?


I have the grid coded in Ext js 4.0. Below is the code:

    var xxx=Ext.create('Ext.grid.GridPanel', {
                    title: 'tableId',
                    id : 'tableId',
                    disableSelection:true,

                    //remaining code

            }

I want to change the value of "disableSelection" dynamically outside the grid according to two different conditions.

How can I do this?


Solution

  • If you're wanting to disable selection of the grid rows (such as in a checkbox selection model) you can use:

    xxx.getSelectionModel().setLocked(true);
    

    To enable selection just use the reverse:

    xxx.getSelectionModel().setLocked(false);
    

    Please see this fiddle for an example: https://fiddle.sencha.com/#fiddle/nf8