views:

50

answers:

1

Is it possible to hide a specific column in jqGrid after it has been setup, while ensuring all alignments are correct (table width and header/data alignment) for IE/FF.

The data can't be removed at back-end w/o major refactoring.

I am reiterating through a specific column and checking if it is all empty, and if so, I tried .remove() on the header and cells for that column, but the alignment goes off seriously (I think setGridWidth is still taking into account that removed column's width). I know there is a hide option when jqGrid initialises... but not sure if there is a method for that post render.

A: 

You can use hideCol and showCol methods for hiding and showing some columns after the jqGrid is created. The method hideCol don't remove any the data from jqGrid but only hide the specified column. See http://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods for detailed.

I recommend you to examain inside of loadComplete event. You can get ids of the loaded data with respect of getDataIDs method, then get the row data in a loop with getRowData and examine there for the empty data. Don't forget to call showCol for all columns which you previously hide. You can just always call showCol for all columns which should be seen and call hideCol with all columns which you will hide.

Oleg
brilliant solution :)
Brandon