修改extjs源碼真正解決:ExtJs4.0 GridPanel 數據內容不能選中復制。


 

extJS 現在依然存在很多bug,有時挺煩人的。比如,最近就需要復制表格信息,extjs的grid卻不支持,研究半天,覆蓋了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" //3、把此處的unselectable="on"改成unselectable="" class="' + Ext.baseCSSPrefix + 'grid-cell-inner ' + Ext.baseCSSPrefix + 'unselectable" style="{{id}-style}; text-align: {align};">{{id}}</div></td>',
                    '</tpl>',
                '</tr>'
            ]

    ...
        });

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM