标签:
jQuery("#jqGrid_id").jqGrid({ ... colModel: [ ... {name:‘price‘, index:‘price‘, formatter:‘integer‘, formatoptions:{thousandsSeparator: ‘,‘}}, ... ] ... });
var datas = [ {"id":1, "name":"name1", "price":123.1, "email":"abc@163.com", "amount":1123423, "gender":"1", "type":"0"}, {"id":2, "name":"name2", "price":1452.2, "email":"abc@163.com", "amount":12212321, "gender":"1", "type":"1"}, {"id":3, "name":"name3", "price":125454, "email":"abc@163.com", "amount":2345234, "gender":"0", "type":"0"}, {"id":4, "name":"name4", "price":23232.4, "email":"abc@163.com", "amount":2345234, "gender":"1", "type":"2"}]?0?2
colModel:[ {name:‘id‘, index:‘id‘, formatter: customFmatter}, {name:‘name‘, index:‘name‘, formatter: "showlink", formatoptions:{baseLinkUrl:"save.action",idName: "id", addParam:"&name=123"}}, {name:‘price‘, index:‘price‘, formatter: "currency", formatoptions: {thousandsSeparator:",",decimalSeparator:".", prefix:"$"}}, {name:‘email‘, index:‘email‘, formatter: "email"}, {name:‘amount‘, index:‘amount‘, formatter: "number", formatoptions: {thousandsSeparator:",", defaulValue:"",decimalPlaces:3}}, {name:‘gender‘, index:‘gender‘, formatter: "checkbox",formatoptions:{disabled:false}}, {name:‘type‘, index:‘type‘, formatter: "select", editoptions:{value:"0:无效;1:正常;2:未知"}} ],
function customFmatter(cellvalue, options, rowObject){ console.log(cellvalue); console.log(options); console.log(rowObject); return "["+cellvalue+"]"; };
function customFmatter(cellvalue, options, rowObject){ } //cellvalue - 当前cell的值 //options - 该cell的options设置,包括{rowId, colModel,pos,gid} //rowObject - 当前cell所在row的值,如{ id=1, name="name1", price=123.1, ...}
jQuery("#grid_id").jqGrid({ ... colModel: [ ... {name:‘price‘, index:‘price‘, width:60, align:"center", editable: true, formatter:imageFormat, unformat:imageUnFormat}, ... ] ... }); function imageFormat( cellvalue, options, rowObject ){ return ‘<img src="‘+cellvalue+‘" />‘; } function imageUnFormat( cellvalue, options, cell){ return $(‘img‘, cell).attr(‘src‘); }
标签:
原文地址:http://www.cnblogs.com/suncici1101/p/5639595.html