! 跨行前需要对数据进行排序
/**
* @author: junson
* @create: 2018-11-16 15:56
* @description: 跨行
*/
$("#id").datagrid({
onLoadSuccess : function(data) {
var position = 0;
var id;
data.rows.forEach(function(item, index) {
if (index != 0) { //跳过第一次循环
if (id != item.id) { //当前item不等于上一个item
if (index - position > 1) { //存在两行以上连续一样的item进行跨行
$("#id").datagrid('mergeCells', {
index : position,
rowspan : index - position,
field : 'username' //你的列属性
});
$("#id").datagrid('mergeCells', {
index : position,
rowspan : index - position,
field : 'address'
});
}
position = index;
}
if (item.id == null) {
position = index;
}
}
id = item.id;
});
}//end onLoadSuccess
});