Reputation: 393
I want to change my grid columns labels, but I have to do it not by their names. Is there a way to change the lable through the column position or through jsonmap? any other way?
Thanks In Advance.
Upvotes: 1
Views: 2739
Reputation: 222017
The answer from tpeczek are based on the documentation of jqGrid, but it's not more correct. After some changes in the code one can't use more column position as the parameter of setLabel method (see the source code). So you have to provide the name of the column. If you have only the position you can get colModel
and get the name
property of the corresponding element of array colModel
:
var iPos = 3, // the position of the column
$grid = $("#gridId"),
colModel = $grid.jqGrid("getGridParam", "colModel");
$grid.jqGrid("setLabel", colModel[iPos].name, "New Label");
I recommend you additionally to read the answer where I provide the code allows to set labels in the JSON input of grid. The demo demonstrate the approach.
Upvotes: 4