You need to sign in to do that
Don't have an account?
TehNrd
How to render a table only if it has values?
I have a page that dynamically returns results to several different tables but I only want these tables to be rendered if they contain values. I would like to put this logic in the page if possible as there are 10 tables and I'd rather not build out 10 methods in the controller if I can do this one a simple line of code in the page.
Here is what I have tried but with no luck. With this code the table is never rendered and I'm not even sure if I can user the .size() method here....
Thanks,
Jason
Message Edited by TehNrd on 08-26-2008 10:25 AM
Here is what I have tried but with no luck. With this code the table is never rendered and I'm not even sure if I can user the .size() method here....
Code:
<apex:pageBlockTable value="{!results}" var="r" rendered="{IF(!results.size() > 0,true,false)}">
Thanks,
Jason
Message Edited by TehNrd on 08-26-2008 10:25 AM
change: IF(!results.size() > 0,true,false)
to: !results.size()>0
expressions evaluate to booleans first anyway.
rendered="{!results != null}"
And this never shows the table, similar to my original code:
rendered="!results.size()>0"
rendered="IF(!results.isempty(),false,true}"
Strange that it saves fine when in the rendered attribute but not the value attribute.
Message Edited by TehNrd on 08-26-2008 09:46 AM
Message Edited by lnryan on 08-26-2008 09:48 AM
Error: The class 'java.util.ArrayList' does not have the property 'size'.
I guess my controller is just going to have ten of these :( .....
Message Edited by TehNrd on 08-26-2008 10:35 AM
That is, assuming you're getting your data from a query, make a variable, e.g. 'myResult' to hold the results of the query. The variable would be a list of whatever objects your query returns. Then make a getter method that returns myList.size() -- an int.
-paul
Message Edited by ptepper on 08-26-2008 10:46 AM
u can use smthing like this :
<apex:pageblockTable id="docTable" value="{!partialList}" rendered="{!NOT(ISNULL(partialList))}" var="docProperty" rows="{!rowCount}" columns="10">
Hello, I 've got the same needs but looks live Visualforce pages does not support size() function
So I did extra cycle before table output to clarify if the object have values for table' rows.
If I have more than zero objects I start table - otherwise skip it
Here is a code:
<apex:variable value="{!0}" var="rowNum"/>
<apex:repeat var="count" value="{!Property__c.Additional_Agreement_Financials__r}">
<apex:variable var="rowNum" value="{!rowNum+1}"/>
</apex:repeat>
<apex:outputPanel id="thePanel" layout="none" rendered="{!rowNum>0}">
<!-- Table here -->
</apex:outputPanel>