Greetings,
I'm trying to figure out how to show and hide a column dynamically.
By using:
$('#list1').setColProp('name',{hidden: false});
This call shows the data for the column but without inserting the whole column. It just inserts the data into the existing column and moves the rest of the data into each adjoining column. So say we have a 3 column table with name, phone, and address but name is defaulted to be hidden. so we have this:
phone | address
————————–
212-1212 | 1233 james
But making the call we get:
phone | address
————————-
tom | 212-1212
The name column is just overwritten into the phone column, phone is then inserted into the address column and the values for address just dropped off. Am I missing some call?
I feel I'm so dang close here 😉
To hide column using JS, you can use:
jQuery("#list1").jqGrid("hideCol","name");
Where name is colname, list1 is grid id.
Thank you Abu, once again your answers are awesome.
One note for future readers of this answer. I found that you will also need to set:
$grid["autoresize"] = false;
Otherwise when you show the columns with call:
jQuery("#list1").jqGrid("showCol","name");
All of the columns will be crashed together.
Thanks again.