permaculture playing cards*
The moose likes JSF and the fly likes Presenting variable number of columns with primefaces datatable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Presenting variable number of columns with primefaces datatable" Watch "Presenting variable number of columns with primefaces datatable" New topic
Author

Presenting variable number of columns with primefaces datatable

Vladislav Simovic
Ranch Hand

Joined: Feb 03, 2011
Posts: 37
I have the following problem my application returns a list of columns form database, and each column has array of its elements. I want to present it on JSF page. Problem is number of columns is not fixed.

So far I have managed to print output via something like this:



But I would like to present it in the form of datatable, i have been using primefaces datatable, but i havent had much success. How can this be done?
karan khosla
Greenhorn

Joined: Apr 27, 2009
Posts: 25



Hope! This Helps.

Cheers!
Karan


Karan Check me out on http://pythonicway.blogspot.com/
Vladislav Simovic
Ranch Hand

Joined: Feb 03, 2011
Posts: 37
karan khosla wrote:

Hope! This Helps.

Cheers!
Karan


Thats just regular datatable, which has one column. I need to be able to make datatable that has varible number of columns that is known in runtime.
Vladislav Simovic
Ranch Hand

Joined: Feb 03, 2011
Posts: 37
I finally resolved this problem, this is how it is done:





More info can be found here: http://www.primefaces.org/showcase/ui/datatableDynamicColumns.jsf;jsessionid=57691A43B05DFACB3DDCB9E7287EF254
Brendan Healey
Ranch Hand

Joined: May 12, 2009
Posts: 218
Whilst p:columns is the most flexible approach if you have the occasional column that
you want to enable/disable you can use p:column rendered=.
Mark Bessem
Greenhorn

Joined: Jul 22, 2011
Posts: 2
Is columns part of richfaces? because richfaces doesn't recognise the tag for me.
Brendan Healey
Ranch Hand

Joined: May 12, 2009
Posts: 218
p: is PrimeFaces http://www.primefaces.org
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Presenting variable number of columns with primefaces datatable