environment:
1.EasyUI Datagrid
2.jsp(s2sh)
3.mysql
//until now i can populate the datagrid plugin with json object normally but a
small issue.
describe:
i got a Json-data-object returned from server,like below:
{"total":28,"rows":[{"productid":"1","attr":{"size":"10dc","color":"red&yellow"},
{"productid":"2","attr":{"size":"102dc","color":"green&null"}
with the plugins:
$(document).ready(function(){
$('#tt').datagrid({
url:'loadVerifyStream.eAction',
pagination:true,
columns:[[
{field:'productid',title:'Product ID',width:100},
{field:'?????',title:'Product Size',width:250},
{field:'?????',title:'product Color',width:100},
]]
});
});
i can’t output ‘Size’ and ‘Color’ attrs to the Grid,I tried
{field:'attr.size',title:'Product Size',width:250},
{field:'attr.color',title:'product Color',width:100},
no work.
anyone knows how to solve this ?
thanks in advance.
//—————————————–
I think i figured this issue out already.
refer to DataGrid’s API:
{field:'color',title:'product Color',width:100,
formatter:function(val,rec){
return rec.attr == null ? "":rec.attr.color;
}}
This is a more general solution:
say your json object is the following:
to get the field name in your fomatter function, use this markup:
then define formatColumn