Dynamically Showing/Hiding Columns

QuestionsDynamically Showing/Hiding Columns
Rick Gopdon asked 10 years ago

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 😉

3 Answers
Abu Ghufran answered 10 years ago

To hide column using JS, you can use:

jQuery("#list1").jqGrid("hideCol","name");

Where name is colname, list1 is grid id.

Rick Gopdon answered 10 years ago

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.

Mario answered 9 years ago

Hi, is it possible this way to show hide colum with the URL? Like ?showCol=name

Your Answer

14 + 6 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?