0

I am trying the show the visualforce page with the pageblock section having id=table1 as hidden when it loads. When the user clicks the Execute button, then only the pageblock needs to be visible. I have assigned the rendered attribute to false. How can I dynamically assign the rendered attribute value to true, when the user clicks the execute button?

VF Page

<apex:page controller="query">
    <apex:form >
     <apex:pageBlock title="Queries">
        Show All Stores <apex:commandButton value="Execute"  action="{!sendQuery}" reRender="table1" />
     </apex:pageBlock>
     <apex:pageBlock id="table1" rendered="false">
       <apex:pageBlockTable value="{!Indexes}" var="i">
            <apex:column value="{!result[i].storeNo}" headerValue="Store No"/>
            <apex:column value="{!result[i].storeName}" headerValue="Store Name"/>          
       </apex:pageBlockTable>    
      </apex:pageBlock>
    </apex:form>
</apex:page>

1 Answer 1

0

You can pass params from apex controller side and display your PageBlockTable

<apex:page controller="DeleteAllBigObject">
    <apex:form >
        <apex:pageBlock title="Queries">
            <apex:commandButton value="View All Stores"  action="{!sendQuery}" reRender="table1">
            </apex:commandButton>
        </apex:pageBlock>
        <apex:pageBlock id="table1">
            <apex:pageBlockTable value="{!Indexes}" var="i" rendered="{!showTable}">
                <apex:column value="{!result[i].storeNo}" headerValue="Store No"/>
                <apex:column value="{!result[i].storeName}" headerValue="Store Name"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller :

public Boolean showTable { get; set; }

In your apex method just do:

showTable = true;

and return null to rerender.

1
  • Thanks again Nagendra. It worked like a charm.
    – Kiran G
    Commented Nov 26, 2020 at 15:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .