We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Accordion closed on load

I would like my accordion to be fully closed on load. Is this achievable? My project uses MVC4.

1 Reply

FP Francis Paul Antony Raj Syncfusion Team January 27, 2016 10:37 AM UTC

Hi Tom,


Thanks for contacting Syncfusion support.


Yes, you can achieve your requirement “Collapse all the header and content panel” using “collapseAll()” method. You need to set the ejAccoridon’s, Collapsible property value to true to enable the collapsible state of the Accordion. Please refer to the following code snippet.

[view]

@Html.EJ().Accordion("basicAccordion").Items(data =>

               {

                   data.Add().Text("Data1").ContentTemplate(@<div>Content1</div>);

                   data.Add().Text("Data2").ContentTemplate(@<div>Content2</div>);

                   data.Add().Text("Data3").ContentTemplate(@<div>Content3</div>);

               }).Collapsible(true).ClientSideEvents(a => a.Create("create"))
[script]

    function create(args) {

        acrdnObj = $("#basicAccordion").data("ejAccordion");

        acrdnObj.collapseAll();

         }


To know more about Accordion properties, methods and events, please refer to the link: http://help.syncfusion.com/js/api/ejaccordion


To know more about getting started with Accordion, refer to: http://help.syncfusion.com/aspnetmvc/accordion/overview

Regards,

Francis Paul A.


Loader.
Up arrow icon