Expand All / Collapse All panes in Ajax Accordion Extender

There is no direct way to Expand/Collapse all panes in Accordion Extender. Using following java script, Accordion can be Expand/Collapse all panes in one click.

Expand All :


            var behavior = $get("<%=accMain.ClientID%>").AccordionBehavior;
            for (var i = 0; i < behavior._panes.length; i++) {
                behavior.get_Pane(i).content.style.display = 'block';
                behavior.get_Pane(i).content.height = behavior.get_Pane(i).content.scrollHeight;
                behavior.get_Pane(i).content.style.height = behavior.get_Pane(i).content.scrollHeight + 'px';
            }



Collapse All :


            var behavior = $get("<%=accMain.ClientID%>").AccordionBehavior;
            for (var i = 0; i < behavior._panes.length; i++) {
                behavior.get_Pane(i).content.style.display = 'none';
                behavior.get_Pane(i).content.height = 0;
                behavior.get_Pane(i).content.style.height = '0px';
            }          
            behavior.set_SelectedIndex(-1);

Comments

Popular posts from this blog

Embedding PowerBI with ASP.NET Core 2 and Angular(2,4,5)

Handling Exit Event of Console Application in C#

CSS text-overflow ellipsis in the beginning of the the text - Left Ellipsis using CSS in a Flex box