I want some space between multiple columns of p:datatable .How can I achieve it without adding any extra blank column in between
Asked
Active
Viewed 2,539 times
0
-
1Look what generated CLIENT SIDE html is and play with the css via your browser developer tool. It's a plain table... – Kukeltje Dec 08 '16 at 14:43
-
What do you mean with "multiple columns"? Do you want space between all columns or between specific column pairs? – Jasper de Vries Dec 08 '16 at 15:24
-
between specific column pairs – Akash D Dec 08 '16 at 15:27
3 Answers
1
A guess, I haven't tried it
.ui-datatable.padding-third-col tbody tr td:nth-child(3) {
padding-right: 5px;
}
Give the datatable styleClass="padding-third-col"
.
Edit: sorry does'nt work for me either. I guess it depends on your theme/styling.
I would just make an extra column like
<p:column styleClass="hidden" style="width: 20px"></p:column>
with
.hidden {
background-color: white;
}
For me, its not enough to give it visibility: hidden
as the row's background shows. Also I need to reset all the borders with something like
table[role=grid], tr, td, th {
border: none !important;
border-collapse: separate;
}
Prefix with the table's styleClass if you like.

Jaqen H'ghar
- 4,305
- 2
- 14
- 26
-
2Works for me. If table width is set to 100% I think it's better to (also) set the column width. – Jasper de Vries Dec 09 '16 at 09:00
-
The edit is not "without adding any extra blank column in between". – Jasper de Vries Dec 12 '16 at 13:45
0
Try This Css
.ui-datatable tbody td {
border-color: inherit;
width: 48px;
overflow: hidden;
display: inline-block;
white-space: nowrap;
}

Kamlesh Delat
- 128
- 11
-
not working..rather all datatable content is coming in one single column – Akash D Dec 08 '16 at 13:45
0
Assuming your p:datatable elements are inside a
<div class="container"> <p:datatable class="data">... </div>
You could change the style of specific p:datatable by:
.container .data:nth-child(n+1){
color:red;
}

Andreas Rau
- 338
- 2
- 11