set colmodel of jqGrid when rows loaded from server but before add to grid

半城伤御伤魂 提交于 2019-12-12 04:46:41

问题


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.

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.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/26469489/set-colmodel-of-jqgrid-when-rows-loaded-from-server-but-before-add-to-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!