How to solve the data loss problem when jqGrid pages, jqgrid pages
When I use jqGrid in a project, I load server data asynchronously, for example, loading data when I click pages or search. This will cause a problem.
Problem description:
When deleting a list in batches, you can select multiple records and select the first record on the current page,
Click the next page and select some records. When you click Delete, the selected records on the previous page cannot be deleted.
Solution:JqGrid does not seem to solve this problem, so you can only write your own code to save the selected records. Two jqGrid event methods are required:
/** Multiselect is true, and this event is triggered only when you click the checkbox in the header. ARowids: the id set of all selected rows. It is an array. Status: the boolean variable indicates the selection status of the checkbox. If it is set to true, false is not selected. Whether or not checkbox is selected, aRowids always has a value **/onSelectAll (aRowids, status)/** to trigger this event when selecting a row. Rowid: id of the current row; status: Select status. This parameter is available only when multiselect is set to true **/onSelectRow (aRowids, status)
General Code
// Save the Array var selectIds = new Array (); jQuery ("# gridid") of the selected record "). jqGrid ({onSelectAll: function (aRowids, status) {if (status = true) {$. each (aRowids, function (I, item) {saveIdToArray (item) ;})} else {$. each (aRowids, function (I, item) {deleteIdFromArray (item) ;}}, onSelectRow: function (aRowids, status) {if (status = true) {// select saveIdToArray (aRowids);} else {// cancel deleteIdFromArray (aRowids) ;}}) // save it to the Array function saveIdToArray (item) {var exit = false; for (var I = 0; I <selectIds. length; I ++) {if (item = selectIds [I]) {exit = true; break ;}} selectAssets. push (item) ;}}// delete function deleteIdFromArray (item) {if (selectIds. length> 0) {for (var I = 0; I <selectIds. length; I ++) {if (item = selectIds [I]) {selectIds. splice (I, 1); break ;}}}}
Only the array can be operated.
The above is a small series of solutions to the loss of data selected during the jqGrid page turning, I hope to help you, if you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!