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

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

问题描述

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

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

推荐答案

根据jqGrid 文档colNames 网格创建后无法更改.

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天全站免登陆