Is it possible to load from server via ajax JQGrid structure(columns) together with data ? If possible, could you please show an example ?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- Carriage Return (ASCII chr 13) is missing from tex
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
You can create jqGrid with all hidden columns. You need create grid with large enough number of columns. The names of the columns (in
colModel
) can have some generic values like"c1"
,"c2"
,"c3"
... The response from the server can containscolModel
information together with the data. Inside ofbeforeProcessing
callback you can changecolModel
and set new column headers. The answer demonstrates setting of column headers dynamically. The code column be simplified by usagesetLabel
method. Another answer demonstrates how to usesetColProp
to set the most settings ofcolModel
full dynamically. If you would combine the solution with the usage ofsetColWidth
method which I posted in the answer (see here too) then you could create perfect solution.There's no reason why not, you just ned to do things (asynchronously) in the correct order, something like this (forgive the psuedo code)
This will get you part of the way there. I guess you'll also be wanting to load Data via Ajax in which case you can set the "Data" option on the jqGrid settings to a callback function (this is not very well documented) - OR you could fire off TWO ajax calls, one for data and one for structure and then when they're BOTH back munge the two together and instantiate your grid object