If you don't mind doing this for every grid on the page, I'd take the direct route and override the templates that generate the html.
Both the Ext.view.TableChunker.metaRowTpl and the Ext.grid.View cls default must be modified. As an added bonus, refresh on Ext.view.Table invokes table.unselectable so you have to override this method, too.
Something like:
Code:
<style type="text/css">
.x-selectable, .x-selectable * {
-moz-user-select: text!important;
-khtml-user-select: text!important;
}
</style>
...
Ext.view.TableChunker.metaRowTpl = [
'<tr class="' + Ext.baseCSSPrefix + 'grid-row {addlSelector} {[this.embedRowCls()]}" {[this.embedRowAttr()]}>',
'<tpl for="columns">',
'<td class="{cls} ' + Ext.baseCSSPrefix + 'grid-cell ' + Ext.baseCSSPrefix + 'grid-cell-{columnId} {{id}-modified} {{id}-tdCls} {[this.firstOrLastCls(xindex, xcount)]}" {{id}-tdAttr}><div class="' + Ext.baseCSSPrefix + 'grid-cell-inner ' + Ext.baseCSSPrefix + 'selectable" style="{{id}-style}; text-align: {align};">{{id}}</div></td>',
'</tpl>',
'</tr>'
];
Ext.override(Ext.grid.View, {
cls: Ext.baseCSSPrefix + 'grid-view ' + Ext.baseCSSPrefix + 'selectable'
});
Ext.override(Ext.view.Table, {
refresh: function(firstPass) {
var me = this,
table;
//this.saveScrollState();
me.setNewTemplate();
// The table.unselectable() call below adds a selectstart listener to the table element.
// Before we clear the whole dataview in the callParent, we remove all the listeners from the
// table. This prevents a big memory leak on IE6 and IE7.
if (me.rendered) {
table = me.el.child('table');
if (table) {
table.removeAllListeners();
}
}
me.callParent(arguments);
//this.restoreScrollState();
if (me.rendered) {
// Make the table view unselectable
table = me.el.child('table');
if (table) {
//table.unselectable();
}
if (!firstPass) {
// give focus back to gridview
me.el.focus();
}
}
}
});
I'd love to hear a better way of doing this...
I really, really wish this had made it into the final 4 release. The workaround for selecting text in 3.x was much easier... I just don't understand why Sencha thinks we don't need this feature. It's been in the Grid Faq for 2-3 forever. IMHO, incorporating all the hacks and workarounds from the FAQ's should have been step number 1 in the redesign process. Why make us reinvent this again?