6

I have multiple datatables on the request form. I want to remove the border for all the datatables except for one. I have used the below style to remove the border. Can you please let me know how can I get only one datatable with borders. As of now, it removes the border for all datatables.

.ui-datatable .ui-datatable-data td, .ui-datatable .ui-datatable-data-empty td {
  border-style: none;
}
Real Chembil
  • 261
  • 2
  • 7
  • 23

1 Answers1

10

Give the table in question a specific style class:

<p:dataTable ... styleClass="borderless">

So that you can use more specific CSS selectors for this:

.ui-datatable.borderless .ui-datatable-data tr,
.ui-datatable.borderless .ui-datatable-data-empty tr,
.ui-datatable.borderless .ui-datatable-data td,
.ui-datatable.borderless .ui-datatable-data-empty td {
    border-style: none;
}

(note that I extended the selector to cover tr as well; it has by default also a border, your initial selector removes only the vertical border between the columns, not the horizontal border between the rows)

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Very helpful! But in my case, it doesnt't work for the column headers. They still have borders. – Turbokiwi Jun 12 '13 at 08:03
  • @Turbokiwi: the question was not how to remove *all* borders from a datatable, but the question was how to apply the given CSS on a specific datatable instead of *all* datatables. – BalusC Jun 12 '13 at 10:00
  • @BalusC It doesn't work for me. All borders still appearing. I am using primefaces 3.5 – John Alexander Betts Sep 18 '13 at 18:47
  • @JohnB: the question was not how to remove *all* borders from a datatable, but the question was how to apply the given CSS on a specific datatable instead of *all* datatables. I have updated the question title accordingly. – BalusC Sep 18 '13 at 18:50
  • @BalusC I published a question about that [here](http://stackoverflow.com/questions/18880208/remove-all-border-on-a-specific-datatable) Could you help me please? – John Alexander Betts Sep 18 '13 at 19:05