4

In jqGrid I am using selectable columns for displaying the columns. Now if I want to store those selected column names in a database and at the time of loading the grid I want to display only the columns which is selected previously then how can I implement that?

Another point is when I load only selectable columns and if I press add button then it displays only the fields which are selected in the jqGrid, but I want to display all the fields while creating the record in the add form.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Bhavik Ambani
  • 6,557
  • 14
  • 55
  • 86
  • 5
    Probably you need just save which columns were previously visible and save the order of the columns. Look at [the answer](http://stackoverflow.com/a/8436273/315935). – Oleg Jul 30 '12 at 10:10
  • @Oleg Excellent answer. But I want to know how to store the currently selected column names and order in database ? – Bhavik Ambani Jul 30 '12 at 10:54
  • 6
    @BhavikAmbani: The functions `saveObjectInLocalStorage` and `getObjectFromLocalStorage` will be called to save and to restore the state of the grid in the `localStorage`. You can just replace the functions to the `ajax` requests which save/get the information to/from the database. – Oleg Jul 30 '12 at 12:26
  • 3
    @Oleg: just post that as an answer, would help other people for sure :-) – SamiSalami Aug 10 '12 at 15:04
  • @RobinMaben Why this should be removed from unanswered list ? I Have not received any answer till now. – Bhavik Ambani Sep 02 '12 at 05:23
  • So I guess you're the one doing all the revenge down votes? I just meant that if @Oleg posted an answer this question would **automatically** disappear from the unanswered list. – Robin Maben Sep 02 '12 at 05:30
  • @RobinMaben But he has not posted any answer yet. – Bhavik Ambani Sep 02 '12 at 09:14

1 Answers1

1

You can save the fields in database as CSVs or anything, and on fetching you can specify the colModel and colNames which would make the grid show only the fields specified.

Taha Rehman Siddiqui
  • 2,441
  • 5
  • 32
  • 58