0

I need to hide all borders of all panelGrids using primefaces. The following code remove the borders on all panelGrids and dataTables too (primefaces 5+):

.ui-panelgrid tr, .ui-panelgrid td {
    border: none;
}

I need this effect only in panelGrids. After that and I need to know how to show the borders only in some panelGrids

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
John Alexander Betts
  • 4,718
  • 8
  • 47
  • 72

1 Answers1

2

Your CSS selectors are to 'broad'. They influence all <tr> and <td> tags that are descendants of a .ui-panelgrid, including all that are in a table that is in a panelgrid cell as descendants of the table that makes the datatable. So you have to make your selectors more specific (read about css specificity on mozdev) and have them only target a certain level .

Use e.g.

.ui-panelgrid > * > tr, .ui-panelgrid > * > tr > td.ui-panelgrid-cell {
     border: none;
}

This only targets <tr>'s that are a grandchild of a .ui-panelgrid and its direct <td> children.

If you don't want this applied to all panelgrids, You'll have to use the styleClass referred to in a comment above by @BhavinPanchani. But instead of explicitly adding borders by using a class, you prevent the css above to be applied.

.ui-panelgrid:not(.keepBorder) > * > tr, .ui-panelgrid:not(.keepBorder) > * > tr > td.ui-panelgrid-cell {
     border: none;
}

Just add the keepBorder class to the panelGrids that you want to keep the border. I did not test this last thing, but with a little testing you;

See also

Community
  • 1
  • 1
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • How can I put the borders in one panelGrid when I have applied this solution? – John Alexander Betts Jul 16 '15 at 14:54
  • I'm almost tempted to refer to _"@... I know how to work with those technologies but I don't know how to do what I asked "_, but I won't... (hmmm just did)... I'll update the answer – Kukeltje Jul 16 '15 at 14:58
  • Thanks Kukeltje. I know them but I'm not an expert :) – John Alexander Betts Jul 16 '15 at 15:31
  • :-) ok… but to me (but I might be to outspoken) this is part of css 'basics' and by reading one good introduction, you'll at least know what is all possible. Applying it might fail sometimes then, but SO comes to the rescue then. – Kukeltje Jul 16 '15 at 16:22