您的位置:首页 > Web前端 > JavaScript

Extjs的grid表格的复制、粘贴

2014-01-08 17:26 393 查看
局部定义表格复制、粘贴的样式:

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后引入)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: