0

Can any body help me to sort out my problem?

The problem is: as I have checked some checkbox and than searching using text box or sorting the column, the checked checkbox can not reatin as checked.

Here is my code snippet:

// 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();
        },
    });
}
    }
    }

This is HTML: <table id="jqGrid"></table>

enter image description here

nim
  • 509
  • 6
  • 16
  • Which version of jqGrid you use and from which fork of jqGrid ([free jqGrid](https://github.com/free-jqgrid/jqGrid), commercial [Guriddo jqGrid JS](http://guriddo.net/?page_id=103334) or an old jqGrid in version <=4.7). Moreover it would be helpful if you include test data for `mydata` instead of posting PHP code. Posting URL to working demo (in JSFiddle for examle) would be more better. Free jqGrid fork, which I develop, supports `multiPageSelection: true` option ([here](http://stackoverflow.com/a/33021115/315935)), which can be combined with `multiselect: true`. It should solve the problem. – Oleg Aug 12 '16 at 11:38
  • Sry olega for incoveniency, I am using jqGrid JS - v5.1.1 - 2016-06-08. I have already set multiselect:true, but still the same problem – nim Aug 12 '16 at 11:53
  • and yes let me add my code snippet in jsfiddle with sample data – nim Aug 12 '16 at 11:55
  • It was posted [this](http://www.trirand.com/blog/?p=1438) short time after publishing jqGrid 4.7. In other words there are exist no more jqGrid after 4.7. The main fork of jqGrid have another product name: Guriddo jqGrid JS and it's not free - one have to buy it for [the prices](http://guriddo.net/?page_id=103334). Because of that I started **alternative fork** under the name [free jqGrid](https://github.com/free-jqgrid/jqGrid), which are based on jqGrid 4.7. I rewrote many parts and implemented many new features holding compatibility with old versions. v5.1.1 is Guriddo and I can't help you. – Oleg Aug 12 '16 at 12:05
  • To try to use free jqGrid you need just change the URLs to jqGrid files. You have load the files from CDN (see [the wiki](https://github.com/free-jqgrid/jqGrid/wiki/Access-free-jqGrid-from-different-CDNs)) or to get from npm ([here](https://www.npmjs.com/package/free-jqgrid)), bower, NuGet ([here](https://www.nuget.org/packages/free-jqGrid)) or [Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cfree-jqgrid). [**The demo**](http://www.ok-soft-gmbh.com/jqGrid/OK/multiPageSelection.htm) demonstrates the usage of **both** `multiPageSelection: true` and `multiselect: true`. – Oleg Aug 12 '16 at 12:09
  • If you can't use free jqGrid then I recommend you to read [the old answer](http://stackoverflow.com/a/8172723/315935). – Oleg Aug 12 '16 at 12:10
  • oleg, I have use the guriddo jqgrid, and here is the same problem what I have just for your reference but my code is bit different from this reference link: http://www.trirand.com/blog/?page_id=393/help/sorting-resets-modified-checkbox-values – nim Aug 12 '16 at 12:13
  • also right now I have make my code small, remove the php code just set sample data, pls look at my que now – nim Aug 12 '16 at 12:17
  • can you please come here: http://chat.stackoverflow.com/rooms/120529/discussion-between-aria-and-oleg – nim Aug 12 '16 at 12:19
  • I can't follow you. jqGrid **resets** selection of sorting, filtering, paging, searching and any other reloading the grid. Thus `selarrrow` will be empty array after sorting or searching. I implemented new option `multiPageSelection: true` in free jqGrid, which changes the behavior and hold the selection over sorting, filtering, paging, searching. – Oleg Aug 12 '16 at 12:21

2 Answers2

1

I recommend you to upgrade to free jqGrid (the current version is 4.13.4). It contains new option multiPageSelection: true, which can be combined with multiselect: true. Adding the option should solve your problem. See the demo, which I prepared for the old answer for more details.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
0

As per oleg suggestion I have just add latest jqgrid jquery in my file, it problem has been solve.

thanks oleg for your help.

nim
  • 509
  • 6
  • 16