Collapse/Expand PanelSplitter by maintaining its state in ADF

0
Add the following JavaScript below the af:document tag in your .jspx page 

< af: resource type="javascript"> 
function toggleSplitter(evt) {
            comp = evt.getSource().findComponent('pt_ps_alert');
            if (comp) {
                comp.setProperty("collapsed", !comp.getProperty("collapsed")); 
            }
        }
< / af:resource> 


 <af:commandImageLink id="list2"
                                                      styleClass="sprite alert pd12R">
  <af:clientListener method="toggleSplitter" type="click"/>
  </af:commandImageLink>

Above javaScript won't maintain the state of Collapse/Expand.

Use below Script to maintain the state in all the pages.

function toggleSplitter(evt) {

        comp = document.getElementById('pt1:pt_ps_alert::i');
        if(document.dispatchEvent){
            var click_ev = document.createEvent("MouseEvent");
            click_ev.initEvent("click", true , true );
            document.getElementById("pt1:pt_ps_alert::i").dispatchEvent(click_ev);
        }
        else {
            comp.click();
        }
     }

pt_ps_alert = PanelSplitter ID

This Script is tested in all browsers.

0 comments: