This is basically a repost of a forum post from the sencha site that can be found here. However, after spending a few hours looking for the solution to the dreaded question, ‘Why can’t I just copy the grid cells and paste them like I used to when the page was a HTML table?”. I thought that I would post the answer I found here so it could reach more people.
First, you will need to add the following CSS in your main stylesheet.
.x-grid-row ,.x-grid-cell, .x-unselectable, .x-unselectable * {
-webkit-user-select: text !important;
-o-user-select: text !important;
-khtml-user-select: all !important;
-ms-user-select: text !important;
user-select: text !important;
-moz-user-select: text !important;
}
Next, just place the following code somewhere in the top of your application javascript file.
if(typeof Ext != 'undefined'){
Ext.core.Element.prototype.unselectable = function(){return this;};
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 + 'unselectable" style="{{id}-style}; text-align: {align};">{{id}}</div></td>',
'</tpl>',
'</tr>'
];
}
Hi,
Thanks for the solution. I have been reallllly trying to fix this issue. I have a doubt though. Where should the code be placed? In which Javascript file? Is it before the load of the grid, or any file which will surely get loaded. Or can you tell me where you had placed it? It would be really helpful if you clarify this. Thanks in advance
Brilliant, fixed it..
Thanks
Please share where did you place the code?
Thanks a lot, great! :)
Great solution!!! Thanks a lot!!! You saved me…