Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set width and margin of <p:column> in a <p:dataTable> ? primefaces

I'm using PrimeFaces 3.4.2 and I have to use <p:dataTable>. I want fixe the width of the first column to less than 5 px. for that I created a css class :

.myTableFlux td:nth-child(1) {
    width: 5px !important;
}

this is my table :

<p:dataTable  value="#{bean.listFlux}" var="list" styleClass="myTableFlux">
    <p:column headerText="Status" >
        <h:graphicImage value="/resources/images/so#{list.i}.jpg" />
    </p:column>
    <p:column headerText="Nom">
        <h:outputText value="#{list.name}" />
    </p:column>
</p:dataTable>

the problem is that I can not go below 5 px.

here is the image that I want to have as a result

like image 434
Karim Oukara Avatar asked Dec 19 '12 09:12

Karim Oukara


1 Answers

For me, the width-Attribute on the p:column tag works with PrimeFaces 3.4:

<p:column width="3" headerText="longlong">
  <h:outputText value="xyz" />
</p:column>

This code will display like this:

Edit: Found a solution to style the padding of certain columns:

<style>
    .ui-datatable td:nth-child(1) div.ui-dt-c {
    padding: 0 0 0 0 !important;
  }
</style>

PrimeFaces can be a little tricky. You have to track down where the attribute comes from, and overwrite the specific styleClasses.

like image 101
Mr. Rabbit Avatar answered Nov 08 '22 23:11

Mr. Rabbit