jqGrid with JSON data renders table as empty

后端 未结 9 2333
孤独总比滥情好
孤独总比滥情好 2020-12-30 06:39

I\'m trying to create a jqgrid, but the table is empty. The table renders, but the data doesn\'t show.

The data I\'m getting back from the php call is:



        
9条回答
  •  醉酒成梦
    2020-12-30 07:16

    Guys just want to help you in this. I got following worked:

    JSON

    var mydata1 = { "page": "1", "total": 1, "records": "4","rows": [{ "id": 1, "cell": ["1", "cell11", "values1" ] },
        { "id": 2, "cell": ["2", "cell21", "values1"] },
        { "id": 3, "cell": ["3", "cell21", "values1"] },
        { "id": 4, "cell": ["4", "cell21", "values1"] }
    ]};
    

    //Mark below important line. datatype "jsonstring" worked for me instead of "json".

    datatype: "jsonstring",
    
    contentType: "application/json; charset=utf-8",
    
    datastr: mydata1,
    
    colNames: ['Id1', 'Name1', 'Values1'],
    
    colModel: [
          { name: 'id1', index: 'id1', width: 55 },
          { name: 'name1', index: 'name1', width: 80, align: 'right', sorttype: 'string' },
          { name: 'values1', index: 'values1', width: 80, align: 'right', sorttype: 'string'}],
    

    Regards,

提交回复
热议问题