动态更改JQgrid列名 [英] changing JQgrid column name dynamically

查看:488
本文介绍了动态更改JQgrid列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需要根据用户从选项列表中选择的内容动态地重命名JQgrid列.我该怎么办?

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

推荐答案

根据

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

但是,您也许可以通过使用几列来模拟列名的更改.然后,您可以隐藏所有这些内容,只有一个会显示给用户.当用户选择另一个时,只需交换选定的列即可.例如,如果有效列为[A,B,C,D],则可能仅显示A.然后,如果用户选择C,则隐藏A并显示C.此方法的主要缺点是您需要复制相同的数据用于许多列.

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.

更新

根据Galichev的回答,您可以使用 setLabel 方法重命名列标题.

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

这篇关于动态更改JQgrid列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆