当前位置: 代码迷 >> ASP.NET >> jqGrid json 不显示数据,该如何处理
  详细解决方案

jqGrid json 不显示数据,该如何处理

热度:1985   发布时间:2013-02-25 00:00:00.0
jqGrid json 不显示数据
$(function(){
  jQuery("#sortrows").jqGrid({
  url:'Handler.ashx',
datatype: "json",
  colNames:['编号','用户名', '实际名称'],
  colModel:[
  {name:'id',index:'id', align:"center"},
  {name:'U_UserName',index:'U_UserName',align:"center"},
  {name:'U_RealName',index:'U_RealName',align:"center"}
  ],
  rowNum:5,
  width:600,
  height: 300,
  rowList:[5,10,15],
  pager: "#psortrows",
  sortname: 'id',
  viewrecords: true,
  sortorder: "desc", 
  caption:"jqGrid控件测试"
}).navGrid("#psortrows",{edit:false,add:false,del:false});
// var mydata = [
// {id:"1",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
// {id:"2",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
// {id:"3",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
// {id:"4",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
// {id:"5",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
// {id:"6",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
// {id:"7",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
// {id:"8",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
// {id:"9",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}
// ];
//for(var i=0;i<=mydata.length;i++)
// jQuery("#sortrows").jqGrid('addRowData',1,mydata[8]);

});


注释部是我测试本地数据,是可以显示的,可就是不显示来至的handler.ashx的数据
上面是js代码


下面是Handler.ashx返回的结果(浏览器查看):

{"page":1,"total":3,"records":3,"rows":[{"id":"1","cell":["1","sqhx","圣桥华玺"]},{"id":"2","cell":["2","cq_zx","重庆赵雄"]},{"id":"12","cell":["12","sh_zszx","上海砧石交易中心"]}]}




------解决方案--------------------------------------------------------
恭喜,接分
------解决方案--------------------------------------------------------
证明有数据 在IE9 无法显示 ,你可以了解下 浏览器的问题