EasyUI Datagrid 数据网格
动态生成table,合计一列数据
例如:在span4中显示出权重的总和
<th data-options="field:'---',width:1000,colspan:2">权重合计:
<span id="span4"></span>
</th>
var weight_total=0;//权重合计
onLoadSuccess : function() {
$("#span4").html(weight_total+"%"); //权重合计
}
//权重合计
rowStyler: function(index,row){
weight_total+=parseInt(row.weights);
//alert(weight_total);
}
parseInt() 函数可解析一个字符串,并返回一个整数。
rowStyler:function(index,row){}
返回例如 'background:red' 的样式。
该函数需要两个参数:
rowIndex:行的索引,从 0 开始。
rowData:该行相应的记录。
代码实例:
$('#dg').datagrid({
rowStyler: function(index,row){
if (row.listprice>80){
return 'background-color:#6293BB;color:#fff;'; // return inline style
// the function can return predefined css class and inline style
// return {class:'r1', style:{'color:#fff'}};
}
}
});