ExtJs4.0 GridPanel 单元格、数据内容不能选中复制的解决办法。

  在extjs2.0的Ext.grid.GridPanel单元格的内容不能选中,没法选中就没法复制,给用户带来很多不便。似乎也没提供属性配置。在网上找到的一些解决办法但不适用于ExtJs4.0。研究半天,覆盖了css,但只在非ie的浏览器有效。修改了extjs源码才解决了在ie的问题。

1、css代码:

 

<style type="text/css">

       .x-grid-row
        {
            line-height:13px;vertical-align:top;padding:0 1px; -moz-user-select:text!important;-khtml-user-select:text!important;-webkit-user-select:text!important;
        }
        .x-grid-cell
        {
            overflow:hidden;font:normal 13px tahoma, arial, verdana, sans-serif;-moz-user-select:text!important;-khtml-user-select:text!important;-webkit-user-select:text!important;
        }
        .x-unselectable
        {
            -moz-user-select:text!important;-khtml-user-select:text!important;-webkit-user-select:text!important;
        }

</style>

 

2、修改extjs4.0的ext-all.js(或ext-all-debug.js)三处代码:

 找到 

Ext.override(Ext.core.Element, {

    ....


            unselectable : function(){
                var me = this;
                me.dom.unselectable = "on";//1、把me.dom.unselectable = "on"修改为me.dom.unselectable = ""
                me.swallowEvent("selectstart", true);//2、把ture改成false
                me.applyStyles("-moz-user-select:none;-khtml-user-select:none;");
                me.addCls(Ext.baseCSSPrefix + 'unselectable');
                return me;
            }

    ...        }); 

 

找到 

Ext.override(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 unselectable="on" class="' + Ext.baseCSSPrefix + 'grid-cell-inner ' + Ext.baseCSSPrefix + 'unselectable" style="{{id}-style}; text-align: {align};">{{id}}</div></td>',
                    '</tpl>',
                '</tr>'
            ]//3、把unselectable="on"改成unselectable=""

    ...
        });

 

这直接修改extjs4.0源代码不怎么友好,但本人extjs水平有限,还望大家提供方法修改。。

(以上在extjs4.0.2a测试通过)

 

转载于:https://www.cnblogs.com/GloomHu/archive/2011/11/22/2259417.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值