changing JQgrid column name dynamically

前端 未结 6 1819
时光说笑
时光说笑 2020-12-10 06:26

I just need to rename JQgrid column dynamically as per user selection from a list of options. How can I do that?

6条回答
  •  孤街浪徒
    2020-12-10 06:54

    According to the jqGrid Documentation, colNames cannot be changed after the grid is created.

    However, you might be able to simulate a column name change by using several columns. Then you can hide all of them except a single one which will be shown to the user. When the user selects another, just swap in the selected column. For example, if valid columns are [A, B, C, D] you might start by only showing A. Then if the user chooses C, hide A and show C. The main disadvantage to this approach is that you will need to copy the same data to many columns, however.

    Update

    Per Galichev's answer, you can use the setLabel method to rename a column header.

提交回复
热议问题