默認的'rowStyler' 選項不支持footer,想讓footer支持rowStyler的話,dategird就得重寫。代碼以下。html
var
myview = $.extend({}, $.fn.datagrid.defaults.view, {
web
renderFooter:
function
(target, container, frozen){
var
opts = $.data(target,
'datagrid'
).options;
var
rows = $.data(target,
'datagrid'
).footer || [];
var
fields = $(target).datagrid(
'getColumnFields'
, frozen);
var
table = [
'<table class="datagrid-ftable" cellspacing="0" cellpadding="0" border="0"><tbody>'
];
for
(
var
i=0; i<rows.length; i++){
var
styleValue = opts.rowStyler ? opts.rowStyler.call(target, i, rows[i]) :
''
;
var
style = styleValue ?
'style="'
+ styleValue +
'"'
:
''
;
table.push(
'<tr class="datagrid-row" datagrid-row-index="'
+ i +
'"'
+ style +
'>'
);
table.push(
this
.renderRow.call(
this
, target, fields, frozen, i, rows[i]));
table.push(
'</tr>'
);
}
table.push(
'</tbody></table>'
);
$(container).html(table.join(
''
));
}
});
$(
'#list'
).datagrid({
view:myview
});
<table id =
"list"
class=
"easyui-datagrid"
title=
"投資狀況統計表"
style=
"width:960;"
fixRowHeight=
"true"
data-options=
"rownumbers:false,singleSelect:true,url:'<%=webRoot %>/hqswq/report/tzqkInfo.do?nf=<%=nf %>',method:'get',showFooter: true,rowStyler: function(index,row){
if (row.fg == '總計'){
return 'color:#fff;font-weight:bold;';
}
}"
>