0

I have a small and rather simple grid that contains a checkbox on each row. The only function the user can do is check or uncheck the boxes and save the results or exit without saving. The update process works fine if the user clicks the save icon, however if they page, any new selections are lost.

Note: the onSelectRow method does not trigger when the checkbox is clicked so the suggested solutions I have found using that technique do not appear to be applicable.

Thank you for any help you can offer.

Here is the grid code:

$( "#PLlist" ).jqGrid({
        url: "pyg280lload.php?st=" + colPCST + "&sq=" + colPCLSEQ,
        datatype: "json",
        loadComplete : function () {
           $("#gridid").jqGrid('setGridParam',{datatype:'local'});
        },
        mtype: "POST",
        colNames:["Row ID", "Select", "State", "Store#", "Store Name", "Seq#", "Store#"],
        colModel:[{name: "PLROWID", hidden:true},
                  {name: "SELSTR", width:50, align:"center", edittype:'checkbox', formatter: 'checkbox', editoptions: {value:"Y:N"}, editable:true, formatoptions: {disabled : false}},
                  {name: "PCST", width:50, align:"center"},
                  {name: "MTSTOR", width:50, align:"center"},
                  {name: "MTNAME", width:240, align:"left"},
                  {name: "PCLSEQ", hidden:true},
                  {name: "MTLVL4", hidden:true}
                 ],
        pager: "#pagerPL",
        emptyrecords: "No records to display.",
        rowNum: 10,
        rowList: [10, 20, 30],
        sortname: "PLROWID",
        sortorder: "asc",
        sortable: true, 
        viewrecords: true,
        gridview: true,
        autoencode: true, 
        height: "100%",
        caption: "<div id='PLlistCaption'>Select Stores</div>"
    }); 

I am also wanting to save the results of the grid in a temporary table or array for either updating the database or discarding. If the user decides to cancel out I do not want to retain any selections that may have been saved.

This grid is for maintaining a relational file to a parent file. If the user decides not to add the parent record or cancels an update I want to discard the data from this grid, however, if they decide to save the updates or commit the add I want to save the relational data to the database.

Right now I am saving it to the database when the user selects "save", the problem is if they cancel out I now have orphaned data in the secondary table.

Again thank you much for any help.

Ray Marsh
  • 13
  • 9
  • Which version of jqGrid you use? Which fork of jqGrid ([free jqGrid](https://github.com/free-jqgrid/jqGrid), [Guriddo jqGrid JS](http://guriddo.net/?page_id=103334) or some old jqGrid in version <=4.7)? How many **total rows** you have which you need to display? Free jqGrid supports for example `multiPageSelection: true` option starting with version 4.10.0. See [the demo](http://www.ok-soft-gmbh.com/jqGrid/OK/multiPageSelection.htm) and [the answer](http://stackoverflow.com/a/33021115/315935). – Oleg Nov 13 '15 at 22:27
  • The version I am using is 4.6.0 This is the name of the folder as it is now "jquery.jqGrid-4.6.0" I do not know if it is free jqGrid or Guriddo jqGrid JS or otherwise. I will have to try to find the person who set it up. As far as the data, there are upwards of 200 rows possible, normally much less. – Ray Marsh Nov 13 '15 at 22:44
  • The problem is not only which version of jqGrid you use, but where you are *able to upgrade*. You can solve many problems by simple replacing jqGrid to more recent version. If you nee to display 200 rows than you should **remove `loadComplete`** which you use and add `loadonce: true` option instead. You should modify the server code to return **all rows** (200 or another number of rows). jqGrid will do paging **locally**. You can use other features like filtering. You will need not to write any additional server code. Just use `filterToolbar` method for example. – Oleg Nov 13 '15 at 22:52

0 Answers0