Bernad Ali
Bernad Ali

Reputation: 1729

Hide Primefaces datatable 'No Records Found' while loading the table content

In my application im loading my data table with default values which placed in first page(After Logged in).while loading data,data table prompts 'No Record Found' which is confusing to the user.how do i hide that while loading in progress ?

enter image description here

Upvotes: 3

Views: 12303

Answers (2)

Janis K.
Janis K.

Reputation: 316

I know it's a bit obvious, but as you display default values anyway, you could set emptyMessage="" in your <p:dataTable>.

However, if you need an emptyMessage to be displayed later (e.g. when user-specific data is to be loaded), you could "disable" it upon first load using something like this:

emptyMessage="#{dataBean.firstLoad ? '' : 'No records found.'}"

where firstLoad would be a method in your backing bean which returns true when the user has just logged in (e.g. default values are to be loaded), and false when not, which would mean that user-specific data should be loaded and the <p:dataTable> could actually be empty.

Upvotes: 6

Daniel
Daniel

Reputation: 37061

Not Tested

I suppose you got some button that is being clicked prior to loading data of the table

so you can add jquery command to hide the row that holds the message for the empty message to its onclick attribute like this

onclick="jQuery('#YourFormIdOrYourTableId .ui-datatable-empty-message').hide();"

you can than

put the line back to visible with jQuery('#YourFormIdOrYourTableId .ui-datatable-empty-message').show();

alternatively, if you are using primefces button you can try

onstart="jQuery('#YourFormIdOrYourTableId .ui-datatable-empty-message').hide();"

onsuccess="jQuery('#YourFormIdOrYourTableId .ui-datatable-empty-message').show();"

calling to the .show() upon success is for enabling the table to display the empty message next time when the table will be empty...

Upvotes: 1

Related Questions