I want to hide some columns in a dataTable(e.g id,serial),the columns will be rendered because javascript need access the value of the columns. Any idea?
            Asked
            
        
        
            Active
            
        
            Viewed 3.7k times
        
    4 Answers
7
            You can use display: none or visibility: hidden. You can find the difference in here: What is the difference between visibility:hidden and display:none?
Whatever you use, you will have access with javascript to those elements.
Also you can find here a interesting point of view regarding the usage of display:none.
- 
                    If primefaces could't do this,the only way may use javascript.Thanks. – machcm.sz Nov 30 '11 at 08:58
- 
                    @machcm.sz This is not Javascript, it's only CSS and the Primefaces components provide `style/styleClass` attribute for situations like this... – spauny Nov 30 '11 at 09:01
- 
                    O,yeayea. I found "display:none;" only hide the div under the td,but td not be affected. The result is 1px line left – machcm.sz Nov 30 '11 at 09:25
- 
                    @spauny: This doesn't answer the question in any way. It just builds exactly on top of my answer. It even starts with "There is no display: hidden." That `hidden` was a type on part. Please, just don't do a drive-by downvote, leave a comment explaining the reason like this. – Bhesh Gurung Nov 30 '11 at 14:29
3
            
            
        Just set the "rendered" attribute to "false":
<p:column rendered="false">
...
</p:column>
 
    
    
        soschulz
        
- 134
- 1
- 4
- 
                    2That does not hide it, using rendered="false" will prevent the column from being part of the HTML page. – Martlark Dec 15 '14 at 00:14
1
            
            
        Did you try this:
<p:column style="display: none" //...
 
    
    
        Bhesh Gurung
        
- 50,430
- 22
- 93
- 142
- 
                    I didn't downvoted your answer even you deserved! How can you say that I don't answer to the question when it's the accepted one. Be careful next time, big guy, and clear that downvote, if you have decency! – spauny Nov 30 '11 at 14:53
- 
                    @spauny: I did think you downvoted my answer. Sorry for that I apologize. But that's not the reason I downvoted your answer, you already know why I downvoted from the comment I posted on your answer. – Bhesh Gurung Nov 30 '11 at 15:26
- 
                    @spauny: Oh yes and I will be more than happy to take it off if you edit you answer to make it look more like an answer to the OP. – Bhesh Gurung Nov 30 '11 at 15:34
- 
                    @spauny: You could still improve it by mentioning where exactly he supposed to use that `display: none`. So that if in the future some one searching for the same problem ends up here, your answer would be sufficient enough to rectify his problem. – Bhesh Gurung Nov 30 '11 at 15:49
0
            
            
        If you are using Prime NG, for angular, in p-column you can add attribute [hidden]="true". That solved my issue. Also, that column will show up in export CSV function which is kind of cool.
 
    
    
        Pulin Jhaveri
        
- 37
- 3
 
     
    