Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set width of empty primefaces datatable

I am using primefaces datatable. How to set width when the table is empty ? because in this case the table smaller when they have some record, I try use style

style="width: 150%" 

or

style="width: 200px"

but with no success.

And it is possible to change default text "No records found." to something else ?

like image 360
hudi Avatar asked Dec 22 '22 11:12

hudi


1 Answers

<p:dataTable style="width:25px;"> will change the width of the table, but the column headers and the message displayed when there are no records also effects the width of the table.

Check the text in your column headers. The text will not line break between words, so the column will have a minium width based on the header text.

<p:column>
    <f:facet name="header">
        <h:outputText value="This is a long column header" />
    </f:facet>
    <h:outputText value="#{bean.value}" />
</p:column>

enter image description here

The No Records Found message will line break between words

enter image description here

so it will only effect the width if one of the words in the message is to long.

<p:dataTable style="width:25px;" emptyMessage="thisisalongmessagefornodata">

enter image description here

like image 176
Mark Avatar answered Jan 07 '23 23:01

Mark