Sort not working with jqGrid

前端 未结 3 2044
梦谈多话
梦谈多话 2020-12-10 19:18

I\'ve been having problems getting jqGrid to sort. I\'d like to preferable do this sorting on the client, but I\'m also willing to make a new call to the database to get th

3条回答
  •  被撕碎了的回忆
    2020-12-10 19:51

    Found one solution, though not entirely sure why this works. Perhaps someone can provide a better answer.

    var x = $("#grid").jqGrid({
        jsonReader: { root: "rows", repeatitems: false },
        datatype: "json",
        height: 'auto',
        autowidth: true,
        forceFit: true,
        colNames:['ID','Name'],
        colModel:[
            {name:'id', key:true, index:'id', width:60, sorttype:"int", jsonmap:"id"},
            {name:'name', index:'name', width:90,  jsonmap: "name"}
        ],
        caption: "Results",
    
        //Required for client side sorting
        loadonce: true,
        gridComplete: function(){ 
          $("#grid").setGridParam({datatype: 'local'}); 
        }
    

提交回复
热议问题