动态更改 JQgrid 列名

编程入门 行业动态 更新时间:2024-10-07 21:32:56
本文介绍了动态更改 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 列名

本文发布于:2023-07-22 00:50:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1182566.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:动态   JQgrid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!