You need to sign in to do that
Don't have an account?
adampro
Display No Results in PageBlockTable
Hi,
I'm making a pageBlockTable to display a list of custom objects. However, there are times where there won't be any objects to display. Is there any way I can make it show that there are no objects returned in the query, rather than it just being a blank table?
I tried this to populate the list with an object that would display 'No records to display', but it returned an error saying : "Error: PartExtension Compile Error: Variable does not exist: Name at line 29 column 52"
(line 29 is the line displayed below)
else{ objectsList.add( new Custom_Object__c (Name = 'No records to display')); }
What other options do I have?
Hello,
Just want to extend the Starz26 idea.
if suppose in Controller you have list name contactList,
then you can check directly if the size of the list is 0 or not.
hope it helps :)
All Answers
You can use the rendered attribute to hide the pageblock table if no records are returned and create a message that displays in its place using the rendered attribute if no records are returned....
I've done a little bit of rerender work, but I'm not sure how to do this exactly. How can I rerender if the controlling list has a size of 0?
Sorry, I'm pretty new to Visualforce & web design.
In the Controller or extension
Public Integer objSize {get;set;}
When you do the SOQL to return the data and assign to a list or whatever, add
objSize = LISTVARIABLE.size(); **This should be what your Pageblock table uses as the Value
Then in your pageblock table add
rendered="{!IF(objSize>0,TRUE,FALSE)}"
Hello,
Just want to extend the Starz26 idea.
if suppose in Controller you have list name contactList,
then you can check directly if the size of the list is 0 or not.
hope it helps :)
why not just use innerContactList.size?
I normally do something like this: