You need to sign in to do that
Don't have an account?

Hide Pageblock Table if there is no values
Hi Friends,
I need help in fixing the VF Pages.
I created a Class and VF Pages where I want to display a Table values. so, I created a Pageblocktable. Now I have 1 issue when I table has values and other table does not have a values it is diplaying both table which looks awkward.
I need to hide the columns if there is no values.
Below is my VF code and Image for your reference.
Kindly advice how can solve this issue.
Thanks.
I need help in fixing the VF Pages.
I created a Class and VF Pages where I want to display a Table values. so, I created a Pageblocktable. Now I have 1 issue when I table has values and other table does not have a values it is diplaying both table which looks awkward.
I need to hide the columns if there is no values.
Below is my VF code and Image for your reference.
<apex:panelGrid columns="3" width="90%"> <apex:pageblock > <apex:pageBlockTable value="{!orderItemsList1}" width="100%" var="div"> <apex:column > <apex:pageBlockTable width="100%" columns="1" border="1" cellspacing="0" cellPadding="1" value="{!div.OrderItems}" var="custom"> <apex:column headerValue="Body" > <apex:outputField value="{!custom.Product2.Name}"/><p class="onepointfive"/> Blue Plates Required:<apex:outputField value="{!custom.Product2.Blue_plates__c}"/><p class="onepointfive"/> <apex:outputText value="Serial No:" /> <p class="onepointfive"/> <apex:outputText value="Work Order #" /> </apex:column> </apex:pageBlockTable> </apex:column> </apex:pageBlockTable> </apex:pageblock> <apex:pageblock > <apex:pageBlockTable value="{!orderItemsList2}" width="100%" var="div"> <apex:column > <apex:pageBlockTable width="100%" columns="1" border="1" cellspacing="0" cellPadding="1" value="{!div.OrderItems}" var="custom"> <apex:column headerValue="Fridge"> <apex:outputField value="{!custom.Product2.Name}"/><p class="onepointfive"/> Blue Plates Required:<apex:outputField value="{!custom.Product2.Blue_plates__c}"/><p class="onepointfive"/> <apex:outputText value="Serial No:" /> <p class="onepointfive"/> <apex:outputText value="Work Order #" /> </apex:column> </apex:pageBlockTable> </apex:column> </apex:pageBlockTable> </apex:pageblock> <apex:pageblock > <apex:pageBlockTable value="{!orderItemsList3}" width="100%" var="div"> <apex:column > <apex:pageBlockTable width="100%" columns="1" border="1" cellspacing="0" cellPadding="1" value="{!div.OrderItems}" var="custom"> <apex:column headerValue="Tail Lift" > <apex:outputField value="{!custom.Product2.Name}"/><p class="onepointfive"/> Blue Plates Required:<apex:outputField value="{!custom.Product2.Blue_plates__c}"/><p class="onepointfive"/> <apex:outputText value="Serial No:" /> <p class="onepointfive"/> <apex:outputText value="Work Order #" /> </apex:column> </apex:pageBlockTable> </apex:column> </apex:pageBlockTable> </apex:pageblock> </apex:panelGrid> <br/>
Kindly advice how can solve this issue.
Thanks.
Use conditional statement to hide/show the pageBlockTable as mentioned below.
<apex:outputpanel rendered = "{!IF(v.orderItemsList1.size >0)}">
<apex:pageBlock>
<apex:pageBlockTable value="{!orderItemsList1}" width="100%" var="div">
</apex:outputPanel>
Hope it helps, if it does mark it as solved.
Thanks
<apex:outputpanel rendered = "{!IF(v.orderItemsList1.size >0)}">
What is v here.
am getting Error unknow property v.
Could you please post a snippet of code which works for you.
Thanks,
Sorry remove "v." annotation.
Thanks
Getting Error,
Expected 3 but received 1.
Kindly advise.
Thanks
<apex:outputpanel rendered = "{!IF(orderItemsList1.size >0, true, false)}">
I hope now you won't get any error. :)
Thanks
Error got rectified but still I could see the empty pageblock table which does not have values.
Thanks
Thanks
Still am seeing Body and Fridge after checking !=0.
Could you please let me know if I need anything to change in class apart from VF.
Thanks.
Please try the below code and let me know if this works for you. If still need modifications do let me know.
VFPage:
Controller:
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi