Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqGrid add new column

I found that in jqGrid plugin for JQuery I can add rows dynamically, but can I do the same with columns? If there would be a simple table I'd prefer to do this manually by hands, but jqGrid stores table information in a lot of divs.

like image 419
Max Frai Avatar asked Nov 20 '10 09:11

Max Frai


People also ask

How do you use jqGrid?

In this step, we are going to add jqGrid Script and CSS reference to index view. This script is added to project when we add jqGrid Grid from NuGet package. After adding Scripts and Css next we need to add table element for reserve the place where the grid should be created.

What is rowNum in jqGrid?

jqGrid exposes a property rowNum where you can set the number of rows to display for each page.

What is jqGrid?

jqGrid is an Ajax-enabled JavaScript control that provides solutions for representing and manipulating tabular data on the web.


1 Answers

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. The usage of jQuery.Remove or jQuery.Empty instead is also possible.

UPDATED: It seems to me that GridUnload is better for your porpose. I created small demo which demonstrate how one can recreate a grid. To be able to use GridUnload or GridDestroy you have to verify that you include grid.custom.js in your project (if you use developer version of the jqGrid) or you have checked "Custom" "Additinal methods" on the jqGrid download page.

UPDATED 2: One can use addColumn method which can be downloaded from here (see jQuery.jqGrid.addColumn.js). The method is still in beta phase. One can find some demos which shows how to use the method here (see addColumnX.htm examples).

like image 121
Oleg Avatar answered Sep 19 '22 11:09

Oleg