$('#xs').datagrid(
{
idFile : 'WARENAME',
width : '98%',
fitColumns : true,
striped : true, //隔行變色
singleSelect : true,
showFooter : true,
columns : [ [
{
field : 'WARENAME',
title : '商品',
width : 20,
align : 'center',
halign : 'center',
styler: function(value,row,index){
if (value =="合計:"){
return 'color:#F89134';
}
}
}, {
field : 'AMOUNT',
title : '數量',
width : 20,
align : 'center',
halign : 'center'
}, {
field : 'CURR',
title : '金額',
width : 20,
align : 'center',
halign : 'center'
} ] ],
onClickRow : function(rowIndex, rowData) {
}
});
function gethouseworktotal(){
datagridtab();
$.ajax({
type : "POST", //訪問WebService使用Post方式請求
url : "ChangeClassServlet",
data : {
changeclassser : "houseworktotal",
classid:classid
},
dataType : 'text',
success : function(text) { //回調函數
if (isSucess(text)) {
var data = $.parseJSON(text);
var XSLIST = {'total':1,'rows':data.XSLIST,"footer":data.XSLIST1};
$('#xs').datagrid('loadData', XSLIST);
}
}
});
}
json:
{"CURRQC":"0","CURRYE":"12390","CURRSJYE":"12390","CURRYH":"0","CURRJC":"12390","CURRYK":"0","XSLIST":[{"WAREID":"1","WARENAME":"上衣","WARENO":"3001","UNITS":"件","AMOUNT":"3","CURR":"1440"},{"WAREID":"2","WARENAME":"大衣","WARENO":"3002","UNITS":"件","AMOUNT":"9","CURR":"7700.60"},{"WAREID":"4","WARENAME":"西便裝","WARENO":"30041","UNITS":"件","AMOUNT":"4","CURR":"3600"},{"WAREID":"5","WARENAME":"T恤","WARENO":"3005","UNITS":"件","AMOUNT":"8","CURR":"2800"},{"WAREID":"21","WARENAME":"牛仔褲","WARENO":"3006","UNITS":"條","AMOUNT":"1","CURR":"280"}],"XSLIST1":[{"CURR":"15820.6","AMOUNT":"25","WARENAME":"合計:"}]}
改變所有合計行的方法我現在還是沒有找到現在才去折中的方式,只改變合計兩個字的 顏色,代碼如下:
columns : [ [
{
field : 'WARENO',
title : '貨號',
width : 20,
align : 'center',
halign : 'center',
styler: function(value,row,index){
if (value =="合計"){
return 'color:#FF7900';
}
}
}]]