Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply wrap text style in JSF datatable?

Tags:

datatable

jsf

I have a data table in my application, I fix the columns width as 200. If i print small line in datatable column means it prints correct format. If i print lengthy line in the datatable column means, it cant wrap it out. how can i wrap the text in data table column.

Problem Description enter image description here

like image 782
PS Kumar Avatar asked Dec 10 '13 12:12

PS Kumar


People also ask

How do you wrap text in JSF?

You can control word wrapping by CSS word-wrap property. Inside tables, this only requires the table-layout property to be set to fixed , so that columns with a fixed width don't auto-expand when their content is larger.

How do you wrap text in a table?

Select the table and either right-click and choose “Table Properties” or pick “Properties” in the floating toolbar. Go to the Table tab in the pop-up window. In the Text Wrapping section at the bottom, select Around and click “OK.” You'll immediately see your table and text move to accommodate each other.


2 Answers

You can control word wrapping by CSS word-wrap property. Inside tables, this only requires the table-layout property to be set to fixed, so that columns with a fixed width don't auto-expand when their content is larger.

E.g.

.fixed-size {
    table-layout: fixed;
    word-wrap: break-word;
}

and

<p:dataTable ... styleClass="fixed-size">
like image 143
BalusC Avatar answered Oct 01 '22 10:10

BalusC


The below worked for me in Chrome not in IE

.preformatted {
    white-space: pre-wrap;
    word-break: break-all;
}
<p:column>
   <h:outputText value="#{bean.txt}" styleClass="preformatted" />
</p:column>
like image 25
Teela Avatar answered Oct 01 '22 11:10

Teela