+ Start a Discussion

Handling PageBlock Table if there is no data present

Hi All,


I am using apex:pageBlockTable tag to render a table in my visualforce page. I would like to display "No Records are avilable" when there is no data to display in table. But I am not sure how to handle this.


Any help on this regard is really appreciated.


- Narendra


 Implement something like this...


<apex:pageBlockTable value="{!YourList}" var="x"

<apex:pagemessage severity="fatal" summary="no results to show"
                            rendered="{!!showresults}" strength="3" />

Shailesh DeshpandeShailesh Deshpande
Hi naren,

1. On your page, you can use the outputPanel tag alongwith rendered attribute. For eg: <apex:outputPanel rendered = {!yourList.size < 1}>"No data available"</apex:outputPanel>

And then on your pageblocktable you simply need to use the below:

<apex:pageblocktable var="v" value={!yourList} rendered = "{!yourList.size > 0}">

NOTE: instead of yourList.size > 0, you can use, NOT ({!yourListsize < 1})

2. You can use a boolean variable in your class (for eg: showResults), which you need to set to true if there are values in your list else false. And then use this variable in your page in the rendered attribute of pageblockTable and outputPanel.