Collapse
PageBlockSection by default on page load
In
a normal Salesforce VF page, the PageBlock Section is not collapsed at the time
of page loading.
But
some times we want a pageblock section to be collapsed by default at the time
of page loading.
We
can do this, with some tricky javascript. We have to get a javascript function
that is a document "onload" handler to call "twistSection"
on the image that is the little twist control for the page block section.
Please
try the following post , which will Collapse PageBlockSection by default on
page load
VF
Code:
------------
<apex:page
tabStyle="MyObject__c" id="myPage">
<script
language="javascript">
/**
<!-- Collapse PageBlockSection on Page Load-->
**/
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
function
dotest() {
if(document.getElementById('myPage:myForm:myBlock:mySection') !=
null){
twistSection(document.getElementById('myPage:myForm:myBlock:mySection').childNodes[0].childNodes[0]);
}
}
addLoadEvent(dotest);
</script>
<apex:form
id="myForm">
<apex:pageBlock
id="myBlock">
<apex:pageBlockSection
title="CollapsablePageBlockSection" collapsible="true"
id="mySection">
Mindfire
Solutions
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form
>
</apex:page>
No comments:
Post a Comment