The user can select the rows by either clicking on that particular row or by clicking the checkbox. JqGrid takes care of the editing of the fields. By clicking the "edit" [pencil] icon at the bottom of the table, users can traverse through the fields of each row and edit the values. This is very similar to what was discussed in the previous section. In Figure 5 below, the row containing the value "COST" has been selected.

One of the important features that a user typically expects with multiselect is deletion. For any deletion to happen, users have to fetch the ID or the rows that need to be passed to the backend for deletion.

JqGrid allows users to fetch the selected rows and the contents using the onSelectRow function. The values within the grid can be fetched using getGridParam. Note the selarrrow parameter to getGridParam. That is not misspelled; it is indeed 'sel' + 'arr' + 'row'. Selarrrow returns an array of IDs of all the fetched IDs.

The backend controller code includes the code for deletion. In the destroy method of the controller class, all the IDs that were marked for deletion are fetched from the params[:id] parameter.

Selarrrow may sound a bit weird and at times users may want to select the ID of just one row. For that, getGridParam('selrow') returns the ID of the presently selected row. You can look into jqGrid's getGridParam documentation for more details on the other methods that are available.

In upcoming articles in this series, the focus will be on selecting and using multiple rows in jqGrid.