The solution would depend on the total number of rows which you need to display. If the number of rows is not large (for example less as 1000 or less as 10000) then the best choice would be return all the data from the server at once. You should add loadonce: true
option to inform jqGrid to read all the data and to save it in the internal data
and _index
parameters. The next important step would be setting the page size not so large, for example 10, 20 or 25. jqGrid will display the first page of data after loading all data from the server. By default jqGrid require that the server return sorted data corresponds to sortname
and sortorder
parameters, which will be send to the server as sidx
and sortd
. On the other side one can use additional option forceClientSorting: true
to force free jqGrid to sort and filter the data before the first page will be displayed.
If one chosen the described above scenario then one can use additionalProperties
option to save additional information for every row of data returned from the server. If you want for example to save the value of Profession
property existing in every item of data then you can use additionalProperties: ["Profession"]
option. After that you can access the data by id using getLocalRow
. The method getLocalRow
works much quickly as getRowData
because it returns just the reference to internal row object, which was read from the server response. It contains all name
properties from colModel
and the properties from additionalProperties
.
The demo https://jsfiddle.net/OlegKi/g8ffxpv2/2/ demonstrates the approach.
You asked additionally how to set title
on some rows based on the content. I'd recommend you to use rowattr
to set any attribute of the row (title
, class
, style
and so on) see the answer or to use cellattr
(see the answer or this one).
Only if one loads really large data and one can't use loadonce: true
option than one can define dummy hidden columns, like {name: "Profession", hidden: true}
instead of usage additionalProperties
. The way is less effective, but it will work. By the way the value of properties used in additionalProperties
could have any type. For example one can include in every item of the main data array of subgrid data in the property (details
, subgrid
). Hidden columns don't allows to load complex data, because the data hate to be not only leaded, but the saved as string in the hidden column (in <td>
elements of the column).