tags:

views:

3336

answers:

4

I have to create a data table simmiliar to the http://www.chartle.net/ have.

The most importang feature is :

  1. Row can be added/remove dynamically (done)
  2. Column can be added/remove dynamically (how can i do this ?)
  3. The changed colModel can be saved in database for feature modification ..

Is this possible ?

+1  A: 

The problem is, that you can't dynamically change the jQgrid ColModel. The two options I see are:

  1. Delete the whole grid and reload it with a new ColModel (if it can change entirely) using GridUnload:

    jQuery(selector).GridUnload(selector);

  2. Load all possible rows and show/hide the ones you need, e.g. by using the show hide columns plugin

For saving it dynamically it should be sufficient to store the configuration data for the grid in the database as JSON.

Daff
+1  A: 

I think it is possible, but haven't tried..

If you use ASP.NET MVC: Have you tried to programmatically add the grid from the Controller as ViewData? It's an idea.

This link may get you further : http://arahuman.blogspot.com/2009/06/jqgrid-using-mvc-json-and-datatable.html

Hope it helps

solkim
A: 

jqGrid 3.6 now supports dynamically showing / hiding columns, and there is a "Column Chooser" demo on their 3.6 demo page. Is this good enough for your needs?

Justin Ethier
A: 

Search getColProp and setColProp in their docs: http://www.trirand.com/jqgridwiki/doku.php?id=wiki%3Amethods

Andrew DeLisa