$('#datagridtwo').datagrid({
iconCls: 'icon-save',
width: '99%',
rownumbers: true,
fitColumns: true,
nowrap: false,
height: 330,
data: [{
"conNo": "电力有限公司", "consName": "中电装备公司", "projectNo": "", "projectName": "", "type": "",
"linkMan": "", "linkPhone": "", "projecttype": "", "projectendTime": ""
},
{
"conNo": "综合能源公司", "consName":"综能服务集团", "projectNo": "", "projectName": "", "type": "",
"linkMan": "", "linkPhone": "", "projecttype": "", "projectendTime": ""
},
{
"conNo": "国家直流技术中心", "consName": "交流中心", "projectNo": "", "projectName": "", "type": "",
"linkMan": "", "linkPhone": "", "projecttype": "", "projectendTime": ""
},
{
"conNo": "直流建设分公司", "consName": "国网直流公司", "projectNo": "", "projectName": "", "type": "",
"linkMan": "", "linkPhone": "", "projecttype": "", "projectendTime": ""
},
{
"conNo": "交流建设分公司", "consName": "国网交流公司", "projectNo": "", "projectName": "", "type": "",
"linkMan": "", "linkPhone": "", "projecttype": "", "projectendTime": ""
},
{
"conNo": "英大公司", "consName": "英大长安", "projectNo": "", "projectName": "", "type": "",
"linkMan": "", "linkPhone": "", "projecttype": "", "projectendTime": ""
},
{
"conNo": "合计", "projectNo": "", "projectName": "", "type": "",
"linkMan": "", "linkPhone": "", "projecttype": "", "projectendTime": ""
},
],
fitColumns: true,
columns: [[
{ field: 'conNo', title: '全称', align: 'center', width: 200 },
{ field: 'consName', title: '简称', align: 'center', width: 100 },
{ field: 'projectName', title: '采集电量(kW.h)', align: 'center', width: 120 },
{ field: 'projectName', title: '未采集分摊电量(kW.h)', align: 'center', width: 100 },
{ field: 'linkMan', title: '分摊系数(%)', align: 'center' },
{ field: 'linkPhone', title: '月分摊电量(kW.h)', align: 'center' },
{ field: 'projecttype', title: '总电量(kW.h)', align: 'center', width: 100, },
{ field: 'projectendTime', title: '总电费(元)', align: 'center', width: 80 },
]],
onLoadSuccess:function(){
var merges = [{
index:6,
colspan:2
}];
for(var i=0; i<merges.length; i++)
$('#datagridtwo').datagrid('mergeCells',{
index:merges[i].index,
field:'conNo',
colspan:merges[i].colspan
});
}
});
重要解决跨行跨列的代码在onLoadSuccess 里 我这里用的是合并指定的单元格。