3

I'm newbie to jqGrid, Can anybody explain what is the use of Index attribute in jqgrid colModel

Alex Kulinkovich
  • 4,408
  • 15
  • 46
  • 50
Den
  • 57
  • 1
  • 7

1 Answers1

7

If you use datatype: "json" or datatype: "xml" without additional usage of loadonce: true parameters then the sorting and filtering of data have to be implemented on the server side. For example if you have the column defined as

{ name: "colName1", index: "colIndex1", ...}

then if the user clicks on the column header jqGrid will send Ajax request to the server with the parameters sidx=colIndex1. So one can use index option to hold the name of the field in the database to simplify building of ORDER BY part of the corresponding SELECT statement.

In the most cases one need to use index property which is the same as name property. In case of usage datatype: "local" or in case of the usage datatype: "json" or datatype: "xml" togather with loadonce: true the data will be saved locally in the grid in data and _index internal options. In the case one need to use index values which are the values from name properties of colModel. In the cases it's strictly recommended don't specify any index property in colModel. In the case jqGrid will use name property instead.

Oleg
  • 220,925
  • 34
  • 403
  • 798