First of all, it is important to understand that jqGrid only supports row selection on the current page . The jqGrid design was completed at a time when local paging was not supported.
The next problem is that you can select data only after the data has been loaded into the grid. For example, you can use loadCompleted to select some rows.
Selecting more than one row is only possible using the multiselect: true option. In the case where jqGrid automatically adds a column with chechboxes and adds a flag in the column header. By checking the chechbox, you can select all the lines on the curect page. Chechbox has an id that has the cb_ prefix and follows with the grid id . For example, it will be cb_template-list if the grid identifier is template-list . So you can use the following code
loadComplete: function () { $("#cb_" + this.id).click(); }
or, if the grid identifier may contain some special characters, itβs better
loadComplete: function () { $("#cb_" + $.jgrid.jqID(this.id)).click(); }
As a result, all lines on each page will be selected immediately after the page is displayed.
UPDATE: The free jqGrid supports the multiPageSelection: true option, which works in combination with multiselect: true . It allows you to hold the selarrrow parameter on many pages. By default, jqGrid will reset the selarrrow array during paging, but if multiPageSelection: true, multiselect: true it does not reload. In addition, it pre-selects all rows from the selarrrow array during page assembly. Thus, if one fills the selarrrow array selarrrow all the columns of the elements (all rows across all pages), then the rows will be displayed selected. The user can still deselect some rows, and jqGrid will not change the changes made by the user.
By the way, you can populate the selarrrow array inside the selarrrow callback if the data is being downloaded from the server.
Oleg
source share