Search code examples
extjsextjs-gridextjs6.2

Workaround for Bug EXTJS-22715 enableTextSelection: true has no effect inside Window


The enableTextSelection attribute doesn't work when grid is inside a window. The following code has no effect on the grid.

viewConfig: {
    enableTextSelection: true
}

See this fiddle for a demonstration: https://fiddle.sencha.com/#fiddle/1jg2 and this sencha forum thread: https://www.sencha.com/forum/showthread.php?331120

The version ExtJs 6.2.0 is affected, but the problem is resolved in ExtJs 6.2.1.

The problem is that there is not ExtJs 6.2.1 GPL release yet.

Is there a workaround for this problem ?


Solution

  • I have fixed your issue please check this fiddle. Here I have added getRowClass() in viewConfig according to given enableTextSelection config. This solved the issue.Reply if any concerns. Below is code :

    id: 'sampleGrid',
    viewConfig: {
        enableTextSelection: true,
        getRowClass: function (record, rowIndex, rowParams, store) {
           var enableTextSelection=Ext.getCmp('sampleGrid').viewConfig.enableTextSelection;
           if(enableTextSelection)
            return "x-selectable";
        }
    },
    

    There is even a simpler way, without adding an id to the grid (because inside getRowClass this refers to the view itself):

    viewConfig: {
        enableTextSelection: true,
        getRowClass: function () {
            return this.enableTextSelection ? 'x-selectable' : '';
        }
    },