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 に答える