3

I created a data table using PrimeNG. I just created 2 headings for the datatable. I'll actually fetch the data from the server, hence if there is no data I do not want the default 'No records found message' to be shown.

I would like the table to be empty if there is no data in the table.

Please take a look at the table that I have created below :

<p-dataTable>
       <p-headerColumnGroup >
         <p-row>
           <p-column header="Weekday"></p-column>
           <p-column header="Set Class Time"></p-column>

         </p-row>
       </p-headerColumnGroup>
 </p-dataTable>
Antikhippe
  • 6,316
  • 2
  • 28
  • 43
Harish
  • 1,193
  • 6
  • 22
  • 45

1 Answers1

9

You can use the emptyMessage property to override this message :

<p-dataTable emptyMessage="">
    ...
</p-dataTable>

Edit : If you don't want to see the border, hide ui-datatable-emptymessage class with CSS. Btw, you don't need to use emptyMessage property anymore in that case.

.ui-datatable-emptymessage {
    display:none;
}
Antikhippe
  • 6,316
  • 2
  • 28
  • 43
  • I'll try it and let you know – Harish Jan 05 '18 at 07:29
  • Yes, it's working. No records found message is hidden now but I'm getting a border for my columns with empty data, Is there a way to avoid it too, I mean is there any default variable with which I can write an if condition to hide the borders – Harish Jan 05 '18 at 07:47