问题描述
我想动态地更改网格的共模型,我做了很多搜索,但没有一个问题线程回答了我。我需要在sql中旋转选择项,因此在执行查询后,我会找到网格的列的名称和计数。
I want to change my grid's colmodel dynamiclly and I did lots of search but non of the question thread answered me. I need to pivot a select in sql so after I execute my query I find out names and count of my grid's columns.
在其他帖子中,我找到了更改colmodel,但我不知道何时何地必须这样做。因为可能会改变结果并降低性能,所以无法两次执行查询。
In other posts I find the way of changing the colmodel but I don`t know when and where I must do it. It is not possible to execute query two time becuase It may changed in result and decrease performance.
推荐答案
一个可以使用 beforeProcessing
回调可以动态地在 colModel
中进行许多修改。一个人不能添加/删除列,一个人不能修改 name
属性,但是最多可以进行其他更改。我建议您使用 setColProp
方法进行修改。可以使用 setLabel
修改列标题。 ,和提供了相应的示例。
One can use beforeProcessing
callback to make many modifications in colModel
dynamically. One can't add/remove columns and one can't modify name
property, but the most other changes are allowed. I would recommend you to use setColProp
method to make the modification. One can use setLabel
to modify column headers. The answer, this one and the another one provides corresponding examples.
我现在正在使用 addColumn
/ removeColumn
列方法,该方法将允许修改 colModel
更深入。您可以在。
I am working now on addColumn
/removeColumn
column methods which will allow to modify colModel
more deep. You can find the current beta version of addColumn
with the corresponding demos on github.
这篇关于从服务器加载行但将其添加到网格之前,设置jqGrid的colmodel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!