+ Start a Discussion

Standard page shown in VF Page, collapsible sections not remembered

Hi all,


I have a question, we have a custom object and the detail layout (standard page layout) is shown in a Visualforce page (so we can have different layouts shown based on the record type). When I collapse a section on the layout and go to another page and go back to the layout, the section is not collapsed anymore. So my question is: is there any way that it can be 'remembered' which sections are collapsed and which aren't, just like you have with the standard functionality?


Kind Regards,



I do not think there is any standard way to retain collapse/expand information in VF pages. Write a function like the following and call it after page is loaded by passing appropriate parameters. Please note that the page will have to remember the last state of the section. That might by done by checking all the section state and passing the information to the next page. 


Sorry to say that I would not do any of  these without asking SFDC support. Please note that following code is not tested and it is modified from the SFDC JavaScript function.



function twistSectionOnLoad(sectionId, collapse) {
   var parentDiv = document.getElementById(sectionId);
   var twisty = document.getElementById('img_' + obj.headerId);
   while (parentDiv.tagName != 'DIV') { parentDiv = parentDiv.parentNode; }
   var div = parentDiv.nextSibling; 
   var elemWasOn = false; 
   if (collapse) { 
       div.style.display = 'none'; 
       twisty.className ='showListButton';
       twisty.alt = twisty.title = 'Show Section - '+twisty.name;
       elemWasOn = true; 
  return !elemWasOn;







Sorry for the late reply, I will pass this information on to a developer so he can have a look whether it will work...I will also ask SFDC Support if they have a solution for this.




There is also an idea that was created a few years ago for this functionality: