0

我有以下代码块:

$("#searchlist").jqGrid({
                url:'./searchlibrary',
                datatype: 'json',
                mtype: 'POST',
                postData: {type: function(){return $('select[name="searchtype"]').val();},
                    criteria: function(){return getSearchData();}
                },
                colNames:['Resource Name','Unit', 'Topic','Document Type','Content Type','Select'],
                colModel :[ 
                  {name:'resourceName', index:'resourceName', width:380, align:'left'}, 
                  {name:'unit', index:'unitID', width:40, align:'center',sortable:true}, 
                  {name:'topic', index:'topicID', width:220, align:'center',sortable:true}, 
                  {name:'docType', index:'docTypeID', width:97, align:'center',sortable:true}, 
                  {name:'contentType', index:'contentTypeID', width:97, align:'center',sortable:true},
                  {name: 'select', index:'resourceID', width:55, align: "center", sortable: false, editable: true, edittype: "checkbox", editoptions: { value:"Yes:No", defaultValue:"No" }, formatter:"checkbox",formatoptions: {disabled : false}}
                ],
                rowNum:20,
                sortname: 'resourceName',
                sortorder: 'asc',
                viewrecords: true,
                gridview: true,
                width:878,
                height:251,
                loadComplete: function(data){
                    initCheckboxes();
                    $('input[type="checkbox"]').click(function(ev){
                        initCheckboxes();
                    });
                }
             });

数据加载得很好,但是当我单击它们不排序的各种列标题时。加载框短暂地显示在数据上,但这些列实际上从未重新排序。排序工作的唯一列是第一列。任何帮助将不胜感激。

4

1 回答 1

3

您为其他列设置的index属性与列名不同。当您对特定列进行排序时,jQGrid 将您在索引处设置的值作为排序参数 (sidx) 传递。

$("#searchlist").jqGrid({
    ...
    colModel :[ 
        {name:'resourceName', index:'resourceName', width:380, align:'left'}, 
        {name:'unit', index:'unit', width:40, align:'center',sortable:true}, 
        {name:'topic', index:'topic', width:220, align:'center',sortable:true}, 
        {name:'docType', index:'docType', width:97, align:'center',sortable:true}, 
        {name:'contentType', index:'contentType', width:97, align:'center',sortable:true},
        {name: 'select', index:'select', width:55, align: "center", sortable: false, editable: true, edittype: "checkbox", editoptions: { value:"Yes:No", defaultValue:"No" }, formatter:"checkbox",formatoptions: {disabled : false}}
    ],
    ...
});
于 2012-07-20T15:21:49.470 回答