function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
An_dyAn_dy 

How to make my page collapsable by default?

Hi,

  When i click on my VF tab then i want to see all my repeat sections collapsable , here is my code but not sure how to make collapse by default, any help is appreciated

 

<apex:page controller="AutomobileDashboard" sidebar="false">

 <h1>Accounts with Related Opportunities</h1>
<apex:form >
<apex:pageBlock id="table"  >
<apex:repeat value="{!accttree}" var="a" id="table">
        <apex:pageblockSection title="{!a.Name}" columns="1" collapsible="true" id="CollapseDefault">
  <table width="100%" cellpadding ="0" cellspacing = "0">                        
 <tr>
  <th>Name</th>
  <th>Status</th>
  <th>Close Date</th>
  <th>Description</th>
  <th>Highlights</th>
  <th>Mitigation</th>
  <th>Region</th>
  <th>Amount</th>
  </tr>   
 <tr>
 <td width='5%'></td>
 <td width='5%'></td>
 <td width='5%'></td>
 <td width='30%'></td>
 <td width='20%'></td>
 <td width='20%'></td>
 <td width='5%'></td>
 <td width='5%'></td>
 </tr>
           <apex:repeat value="{!a.opps}" var="c">
            <tr>
             <td><table> <apex:outputlink value="/{!c.id}" target="_blank">
             <apex:outputtext value="{!c.Name}"/>
            </apex:outputlink></table></td>
            <td><table><apex:outputText label="" value="{!c.Status__c}" escape="false"/></table></td>
             <td><table><apex:outputText label="" value="{0,date,MM/dd/yyyy}"><apex:param value="{!c.CloseDate}" /></apex:outputText></table></td>
             <td><table><apex:outputText label="" value="{!c.Description}"/></table></td>
             <td><table><apex:outputText label="" value="{!c.Highlights__c}" style="white-space:pre-wrap;"/></table></td>
             <td><table><apex:outputText label="" value="{!c.Mitigation__c}" style="white-space:pre-wrap;"/></table></td>
             <td><table><apex:outputText label="" value="{!c.Region__c}"/></table></td>
             <td><table><apex:outputText label="" value="{0,number, ###,###,###,###}">
                         <apex:param value="{!c.Amount}"/>
                        </apex:outputText></table></td>
            </tr>
           </apex:repeat>
 </table>
 </apex:pageblockSection>
    </apex:repeat>
   </apex:pageBlock>
           </apex:form>
</apex:page>

Vinita_SFDCVinita_SFDC

Hello,

 

To achieve this requirement we will have to include a script statement to make collapse default as follows:

 

<apex:page >
<apex:pageBlock id="block1">
    <apex:pageBlockSection id="section1" columns="2" collapsible="true" title="Title">
        Example Area
    </apex:pageBlockSection>
    
<script> twistSection(document.getElementById('{!$Component.block1.section1}').getElementsByTagName('img')[0]) </script>
</apex:pageBlock>
</apex:page>

 

Hope it helps!

An_dyAn_dy

My bad! i mean to say i don't want it to collapse by default. Right now if i click on tab all the sections gets collapsed by default and i can see all the data, but don't want this to be happened. All sections should not collapse and i should not see any data, i want to make only to collpase if i click the dropdown arrow manually. Does this makes sense?

Vinita_SFDCVinita_SFDC

Hello,

 

By default section should not be collapsed unless we are making it collapsible explicitly. I just tried the example given in following link and it is working fine. To implement this example account teams should be enabled in your org, please refer the code in the link and check if you are missiong something:

 

http://www.forcetree.com/2010/04/expand-collapse-pageblock-table-columns.html