排序或搜索后,jqgrid复选框无法保留为已选中状态

时间:2016-08-12 11:04:29

标签: checkbox jqgrid jqgrid-php

任何人都可以帮我解决问题吗?

问题是:由于我检查了一些复选框,而不是使用文本框或对列进行排序,因此选中的复选框无法重新检查。

这是我的代码段:

// PREPARE VARIABLE FOR TABLE DATA FILLUP
var mydata = [
  {"sequence":"sequence","odk":"odk","down":"down"}
];

$(document).ready(function () {
//TO LOAD THE DATA IN TABLE
$("#jqGrid").jqGrid({
    datatype: "local",
    data: mydata,
    height: 250,
    width: 961,
    colModel: [
        { label: 'sequence', name: 'sequence', width: 75 },
                    { label: 'ODK', name: 'odk', width: 75 },
        { label: 'Down', name: 'down', width: 75 },

    ],
    viewrecords: true, // show the current page, data rang and total records on the toolbar
    <!--sortable: true,-->
    colMenu : true,
    shrinkToFit : false,
    multiselect: true,
    caption: "Game Film Search Tool",
});
$('#jqGrid').jqGrid('filterToolbar',{
    stringResult: true,
    //searchOnEnter: false,
    searchOperators : true
});
});

// AS SELECT CHECKBOX FROM TABLE
function getSelectedRows() {

var grid = $("#jqGrid");
var rowKey = grid.getGridParam("selrow");

if (!rowKey)
alert("No rows are selected");
else {
var selectedIDs = grid.getGridParam("selarrrow");
var result = "";
for (var i = 0; i < selectedIDs.length; i++) {
    result += selectedIDs[i] + ",";
}

var reelName = prompt("Please enter a title", "Title");
if (reelName != null) {
    //alert("Saving " + reelName + " with these clips" + result);
    var gameid = $(".schoolid_chk").val();
    var result = result.slice(0,-1);
    $.ajax({
        data:{'reelName':reelName,'result': result},
        type: 'POST',
        dataType:'html',
        url: 'saveReelHeaderAndDetail.php',
        success:function(data){
                $('#savemsg').text(data);
                $('#savemsg').show();
        },
    });
}
    }
    }

这是HTML: <table id="jqGrid"></table>

enter image description here

2 个答案:

答案 0 :(得分:1)

我建议您升级到free jqGrid(当前版本为4.13.4)。它包含新选项multiPageSelection: true,可与multiselect: true结合使用。添加选项可以解决您的问题。有关详细信息,请参阅我为the demo准备的the old answer

答案 1 :(得分:0)

根据oleg建议我刚刚在我的文件中添加了最新的jqgrid jquery,问题已经解决了。

感谢oleg的帮助。