ajax调用方式:
$.each(data.RESULTSET,function(i,ele){ ele.MTUR_YLD = cellRenderNum100(null,"MTUR_YLD",ele.MTUR_YLD); ele.TMT_YLD = cellRenderNum100(null,"TMT_YLD",ele.TMT_YLD); })
source: { localdata : data.RESULTSET, datatype : "array", datafields : [ {name : 'QTN_ID',type : 'int'}, {name : 'TERM_BEG',type : 'string'}, {name : 'TERM_END',type : 'string'}, {name : 'MTUR_YLD',type : 'string',cellsrenderer:cellRenderNum100}, {name : 'TMT_YLD',type : 'string',cellsrenderer:cellRenderNum100} ] },
//取小数点后4位并强制显示小数点后4位 @author zhangyunyang 2014-12-18 function cellRenderNum100(row, columnfield, value){ var value_str=String(value*100); if(value_str.length>6){ value_str=value_str.substring(0,6); }else{ if(value_str.indexOf(".") != -1){ var varr=value_str.split('.'); var rlg=4-varr[1].length; for(var i=0;i<rlg;i++){ value_str=value_str+"0"; } }else{ value_str=value_str+".0000"; } } return value_str; }
原文地址:http://blog.csdn.net/nickroprak/article/details/42005751