动态更改JQgrid列名

编程入门 行业动态 更新时间:2024-10-07 09:16:21
本文介绍了动态更改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:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1182572.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:动态   JQgrid

发布评论

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

>www.elefans.com

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