JQGrid列自定义..在运行时添加列 [英] JQGrid Column Customization ..Add Column at Run time

查看:112
本文介绍了JQGrid列自定义..在运行时添加列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

J Query的新手,正在尝试 http://www.trirand的一些示例.com/blog/jqgrid/jqgrid.html 在这里,我看到列名是用JS编写的,并显示在Grid中.

Am new to J Query and am trying some samples in http://www.trirand.com/blog/jqgrid/jqgrid.html Where i see column names are written in JS which are displayed in Grid.

我有这个要求要在JQGrid上做,以显示他们每次搜索的列.

I have this requirement to do on JQGrid to show the Column they search every time.

示例:我有一组标准列要显示在网格中,例如学生姓名,地址,电话号码.

Example: I have standard set of columns to be displayed in the Grid Like student name, Address,Phone number.

如果用户按学生编号搜索,我需要在结果中添加学生编号作为列.

Suppose if user search by Student id i need to add Student id as column to the result.

我应该像

"student name, Address,Phone number,StudentID"

如果他们按总数搜索

我应该像

"student name, Address,Phone number,Total"

为简化起见,我需要在用户单击搜索后向JQGrid添加一列.

To simplify i need to add one column to JQGrid after user clicks on search.

我可以在JQGrid中执行此操作吗?我该如何实现呢?

Can i do this in JQGrid. How can i implement this ?

推荐答案

此答案来自

不可能将列动态添加到jqGrid.您必须使用colModel再创建一列来重新创建整个网格.如果使用单独的colNames,则数组的大小也必须增加.例如,您可以使用GridDestroy销毁现有网格.您实际上可以像往常一样绑定一个额外的列,但是可以在运行时使用jquery显示/隐藏它们.因此,您可以只添加一列,然后根据需要使用.

It is not possible to add a column to the jqGrid dynamically. You have to recreate the whole grid with colModel having one column more. If you use separate colNames, then the size of the array have to be increased too. You can use GridDestroy for example to destroy the existing grid. you can actually bind an extra column as normal but you can show/hide them at runtime using jquery. So you could just add a column and hide/show it as per your requirement using .

        $("#grid").showCol("column_name");
        $("#grid").hideCol("column_name");

这篇关于JQGrid列自定义..在运行时添加列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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