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
devamitdevamit 

hide pageblocksection

hi..

pageblocksection hide 

 

Message Edited by devamit on 10-13-2009 12:59 AM
Best Answer chosen by Admin (Salesforce Developers) 
prageethprageeth

What about a solution with "innerHTML"..?

 

<apex:page>

<script>

var contentArray = new Array();

var idArray = new Array();

var isCollapsed = false;

 

function collapse(ids){

if (isCollapsed) {

fix();

return;

}

isCollapsed = true;

idArray = ids.split(',');

for (var i = 0; i < idArray.length; i++) {

contentArray[i] = document.getElementById(idArray[i]).innerHTML;

document.getElementById(idArray[i]).innerHTML = '';

}

}

 

function fix(){

isCollapsed = false;

for (var i = 0; i < idArray.length; i++) {

document.getElementById(idArray[i]).innerHTML = contentArray[i];

}

}

</script>

<apex:form>

<apex:pageblock>

<apex:pageblockSection id="ps1">

This is first pageblockSection;<br/><br/><br/>

</apex:pageblockSection>

<apex:pageblockSection id="ps2">

This is second pageblockSection;<br/><br/><br/>

</apex:pageblockSection>

<apex:pageblockSection id="ps3">

This is third pageblockSection;<br/><br/><br/>

</apex:pageblockSection>

 

<apex:commandButton value="Click" onClick="collapse('{!$Component.ps1},{!$Component.ps2},{!$Component.ps3}');return false;"></apex:commandButton>

</apex:pageblock>

</apex:form>

</apex:page>

All Answers

prageethprageeth

What about a solution with "innerHTML"..?

 

<apex:page>

<script>

var contentArray = new Array();

var idArray = new Array();

var isCollapsed = false;

 

function collapse(ids){

if (isCollapsed) {

fix();

return;

}

isCollapsed = true;

idArray = ids.split(',');

for (var i = 0; i < idArray.length; i++) {

contentArray[i] = document.getElementById(idArray[i]).innerHTML;

document.getElementById(idArray[i]).innerHTML = '';

}

}

 

function fix(){

isCollapsed = false;

for (var i = 0; i < idArray.length; i++) {

document.getElementById(idArray[i]).innerHTML = contentArray[i];

}

}

</script>

<apex:form>

<apex:pageblock>

<apex:pageblockSection id="ps1">

This is first pageblockSection;<br/><br/><br/>

</apex:pageblockSection>

<apex:pageblockSection id="ps2">

This is second pageblockSection;<br/><br/><br/>

</apex:pageblockSection>

<apex:pageblockSection id="ps3">

This is third pageblockSection;<br/><br/><br/>

</apex:pageblockSection>

 

<apex:commandButton value="Click" onClick="collapse('{!$Component.ps1},{!$Component.ps2},{!$Component.ps3}');return false;"></apex:commandButton>

</apex:pageblock>

</apex:form>

</apex:page>

This was selected as the best answer
devamitdevamit

hi prageeth,

 

thanks
Message Edited by devamit on 10-13-2009 01:01 AM
ThomasTTThomasTT
prageethprageeth

Hello devamit;

I now again checked my above code with "Firefox", "IE" and "Chrome". It works in all those browsers.

Sometimes the problem may be with the way that you pass the component Ids to the function.

Could you please post a sample piece of your VF markup and then I can try to help you. 

Paulo CastroPaulo Castro

It would be nice to have this feature natively.

 

If you want too, please help to promote this ideia:

 

http://ideas.salesforce.com/article/show/10098227/Add_Collapsedtrue_option_to_ltapexpageblocksection