我正在尝试将数组值传递给 jqgrid。如下,“排名”值是另一个数组,我想将数组中的每个元素(排名和分数)放在单独的列中:
Javascript:
$(document).ready(function(){
jQuery("#ggp_info").jqGrid('GridUnload');
jQuery("#ggp_info").jqGrid({
data: jsonObj.entry,
datatype: "local",
colModel:[
{name:'id',index:'id', width:55, align:"center"},
{name:'name',index:'name', width:110, align:"center"},
{name:'sort',index:'sort', width:50, align:"center"},
{name:'ranking.rank',index:'ranking.rank', jsonmap:'ranking.rank', width:250, align:"center"}
],
rowNum:7,
sortname: 'id',
viewrecords: true,
sortorder: "desc",
height: "100%",
shrinkToFit: false,
caption:"Leaderboard"
});
});
jsonObj值如下:
{“入口”: [{"id":"10000935","name":"Queen","sort":"0","ranking":[{"rank":"1","score":"60"}]} , {"id":"10000936","name":"Level1","sort":"0","ranking":[{"rank":"1","score":"700"}]}]