在datagrid的onLoadSuccess事件增加代码处理。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<style type=
"text/css"
> .subtotal { font-weight: bold; }
/*合计单元格样式*/
</style>
<script type=
"text/javascript"
>
function
onLoadSuccess() {
//添加“合计”列
$(
'#table'
).datagrid(
'appendRow'
, {
Saler:
'<span class="subtotal">合计</span>'
,
TotalOrderCount:
'<span class="subtotal">'
+ compute(
"TotalOrderCount"
) +
'</span>'
,
TotalOrderMoney:
'<span class="subtotal">'
+ compute(
"TotalOrderMoney"
) +
'</span>'
,
TotalOrderScore:
'<span class="subtotal">'
+ compute(
"TotalOrderScore"
) +
'</span>'
,
TotalTrailCount:
'<span class="subtotal">'
+ compute(
"TotalTrailCount"
) +
'</span>'
,
Rate:
'<span class="subtotal">'
+ ((compute(
"TotalOrderScore"
) / compute(
"TotalTrailCount"
)) * 100).toFixed(2) +
'</span>'
});
}
//指定列求和
function
compute(colName) {
var
rows = $(
'#table'
).datagrid(
'getRows'
);
var
total = 0;
for
(
var
i = 0; i < rows.length; i++) {
total += parseFloat(rows[i][colName]);
}
return
total;
}
</script>
|
本文转自问道博客51CTO博客,原文链接 http://blog.51cto.com/450236/1839223如需转载请自行联系原作者 crackernet |