实现Extjs的grid表格的复制、粘贴

写了几个JSON格式数据绑定的grid网状表格,发现表格内的数据不能复制粘贴,只能read...

而又需要使用其中的某行数据,要求能方便快捷操作。

解决方法,如下:



局部定义表格复制、粘贴的样式:

1.在jsp、html中的<head></head>中添加css样式:

<style type="text/css"> 
     .x-selectable, .x-selectable * {  
          -moz-user-select: text!important;  
          -khtml-user-select: text!important;  
      }  
  </style> 

 

2.在grid中添加:

grid=new Ext.grid.GridPanel({
        viewConfig: {     
    templates: {    
     cell: new Ext.Template(  
       '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id}   x-selectable {css}" style="{style}"   tabIndex="0" {cellAttr}>', 
       '<div class="x-grid3-cell-inner x-grid3-col-{id}"  {attr}>{value}</div>',
       '</td>'
        )
     }  
   },

....})

 

 

全局定义复制、粘贴的样式:

1、在*.css文件中添加样式: 

.x-selectable, .x-selectable * {  
          -moz-user-select: text!important;  
          -khtml-user-select: text!important;  
      } 

2、新建一个js文件,写入如下内容:

if (!Ext.grid.GridView.prototype.templates) {
   Ext.grid.GridView.prototype.templates = {};
}
Ext.grid.GridView.prototype.templates.cell = new Ext.Template(
   '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} x-selectable {css}"  style="{style}" tabIndex="0" {cellAttr}>',
   '<div class="x-grid3-cell-inner x-grid3-col-{id}" {attr}>{value}</div>',
   '</td>'
);

3、在每一个需要复制,粘贴的grid的中引入此js(注:必须在ext-all.js后引入)








转载自:http://blog.sina.com.cn/s/blog_66a219dd0100s0ox.html




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值