Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set p:dataTable p:column width

Tags:

I am trying to set the column widths of my data table. I have looked at this question for an answer How to set width of a p:column in a p:dataTable in PrimeFaces 3.0?.

I am however trying to do something a little bit different. I only want the column to be as wide as the widest element it it is displaying. Most of my data is text.

So for example, it should not look like this

-----------------------------
| This is some text         |
-----------------------------

It should look like this

---------------------
| This is some text |
---------------------

If there are multiple rows, the coulmn should be as large as the widest element.

like image 710
user489041 Avatar asked Sep 11 '13 18:09

user489041


2 Answers

I always use

<p:dataTable ........ tableStyle="width:auto">

And does what I think you expect your datatable to do.

like image 64
Maco Avatar answered Sep 28 '22 10:09

Maco


If you want the table width remain 100%, use

tableStyle="table-layout: auto;"
like image 40
Szarpul Avatar answered Sep 28 '22 10:09

Szarpul