JqGrid dynamic columns

I am using jqGrid v4.4.5 and I want to create it with dynamic columns. It is populated with the file "jqGridHandler.ashx". I want to send JSON all the information (column name, data, ...). I am looking for it on Google, but cannot find a good answer.

By clicking on each grid (w630> (child) change the entire grid (actions and columns ...). For example, clicking node 3, the grid has three columns: "A" and "B" and "actions", but by clicking on the grid of node2 there are columns "C" and "D" and "actions". enter image description here

0
jqgrid
Apr 24 '13 at 11:45
source share
2 answers

You can use jqGrid to create many different grids, grids, subgrids, etc. It is very important to understand if you want to display a grid with 10 rows or 100,000 rows. If you have 100,000 rows (or some other large number of rows), you will have to implement server-side swapping and data sorting. Therefore, if the user clicks the "next page" button, the following lines must be downloaded from the server. Why do you need to send all colModel data for a search query or sort? Therefore, you should clearly understand that in the server-side scenario, you need to create all the grid structures only once, and then only the grid body needs to be updated. Therefore, it would be nice to send all the information (column name, column model, data, ... right away).

Only if you have several hundred or several thousand rows in the grid and you can use the loadonce: true parameter, you can upload all the information (column name, column model, data, ...) once to a separate jQuery.ajax call, and then create a jqGrid using datatype: "local" and using the data parameter, which contains all the grid data.

UPDATED . If you need to change

 // in the example below the grid with id="list" will be created // with column having name: "c4" in colModel var $grid = $("#list"), columnName = "c4"; ... var $colHeader = $("#jqgh_" + $.jgrid.jqID($grid[0].id) + "_" + $.jgrid.jqID(columnName)), $sortingIcons = $colHeader.find(">span.s-ico"); // change the text displayed in the column $taxHeader.text("New header text"); // append sorting icons to the new text $taxHeader.append($sortingIcons); 
+1
Apr 24 '13 at 15:12
source share

Before initializing jqGrid, you will need information for your colNames and colModel properties for jqGrid.

In short, you will request information from your server, as soon as you successfully extract this information, you can build jqGrid, and then jqGrid can go and extract the data.

The following article has sample client-side code: jqGrid and dynamic column binding

+1
Apr 24 '13 at 13:42 on
source share



All Articles