1

I have a pageblocktable that is inside pageblocksection. The pageblocktable has many columns. I want 1 of the columns to appear only if it exist.

Following is my code...

   <apex:pageblocksection title="Order infos" showheader="true" collapsible="true" columns="1">           
              <apex:pageBlockTable value="{!gp.con}" var="p">   
                <apex:column colspan="7"> 
                    <apex:facet name="header">#</apex:facet>
                    <apex:outputLink value="/{!p.id}"><apex:outputText value="{!p.Name}"/>
              </apex:outputLink>
                </apex:column>
                 <apex:column>
                     <apex:facet name="header">Material Name</apex:facet>
                     <apex:outputText value="{!p.gew_material_name__c}"/>
                 </apex:column....

I dont wan't the below nested table Shipment Info for the Order infos if there are no shipments info available.

                <apex:pageblocksection title="Shipment Info"  collapsible="true" columns="1">
                    <apex:pageBlockTable value="{!gp.opp}" var="q">
                          <apex:column > 
                                 <apex:facet name="header">Shipment Lines</apex:facet>
                                 <apex:outputLink value="/{!q.id}"><apex:outputText value="{!q.Name}"/>          
                           </apex:outputLink>
                          </apex:column> gew_quantity_shipped__c

For now a blank pagetable with all the column header shows like the below image. Ineed to show shipment info only if there are values, records. No NULL Shipments!! Is this possible through rendered or javascript?

  • Try adding rendered = {!NOT(ISNULL(gp.opp))}. ie <apex:pageblocksection title="Shipment Info" collapsible="true" columns="1" rendered = {!NOT(ISNULL(gp.opp))}> – Rao Sep 23 '14 at 21:05
  • Thnx rao for replying the quick reply. Your answer helped. Thanks! – MnZ Sep 24 '14 at 6:35
2

Posting my comment as an answer:

rendered attribute should help you hide the page block section.

Try adding

rendered = {!NOT(ISNULL(gp.opp))}

. ie

<apex:pageblocksection title="Shipment Info" collapsible="true" columns="1" rendered = {!NOT(ISNULL(gp.opp))}> 
| improve this answer | |
3

You can in fact used the rendered attribute to do this. For the :

<apex:pageblocksection title="Order infos" showheader="true" collapsible="true" columns="1">  

you need to put logic in the controller to check the columns of each row and you can then use that variable on the columns.

The next one is easy:

 <apex:pageblocksection title="Shipment Info"  collapsible="true" columns="1" rendered="{!gp.opp.size > 0>

Better yet, you can have a getter inside your controller to keep the VF page more polished.

 <apex:pageblocksection title="Shipment Info"  collapsible="true" columns="1" rendered="{!hasShipments}">

public boolean hasShipments()
{
  return !gp.opp.isEmpty();
}
| improve this answer | |
  • Thnx @dphil I got the idea after you posted your answer. rao's answer in comment did the trick. I tried your suggestions, I got this error " The value 'null' is not valid for operator '>' Error is in expression". I should have mentioned that it was retruning NULL. Thnx! – MnZ Sep 24 '14 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.