Search results

Expand and Collapse

Collapsible panes

The Splitter panes can be configured with built-in expand and collapse functionalities. By default, the collapsible behavior is disabled. Enable the Collapsible behavior in the paneSettings property to show or hide the expand or collapse icons in the panes. You can dynamically expand and collapse the panes by the corresponding icons.

The following code shows how to enable collapsible behavior.

@using Syncfusion.EJ2.Blazor
@using Syncfusion.EJ2.Blazor.Layouts

<EjsSplitter Height="200px" Width="600px" SeparatorSize=2>
    <SplitterPanes>
        <SplitterPane Collapsible="true">
            <ContentTemplate>
                <div class="content">
                    <h3 class="h3">PARIS </h3>
                    Paris, the city of lights and love - this short guide is full of ideas for how to make the most of the romanticism...
                </div>
            </ContentTemplate>
        </SplitterPane>
        <SplitterPane Collapsible="true">
            <ContentTemplate>
                <div class="content">
                    <h3 class="h3">CAMEMBERT </h3>
                    The village in the Orne department of Normandy where the famous French cheese is originated from.
                </div>
            </ContentTemplate>
        </SplitterPane>
        <SplitterPane Collapsible="true">
            <ContentTemplate>
                <div class="content">
                    <h3 class="h3">GRENOBLE </h3>
                    The capital city of the French Alps and a major scientific center surrounded by many ski resorts, host of the Winter Olympics in 1968.
                </div>
            </ContentTemplate>
        </SplitterPane>
    </SplitterPanes>
</EjsSplitter>

<style>
    .content {
        padding: 10px;
    }
</style>

The output will be as follows.

Expand and Collapse

Programmatically control the expand and collapse action

The Splitter provides public method to control the expand and collapse behavior programmatically using the Expand and Collapse methods. Refer to the following code example.

@using Syncfusion.EJ2.Blazor
@using Syncfusion.EJ2.Blazor.Layouts
@using Syncfusion.EJ2.Blazor.Buttons

<EjsSplitter @ref="SplitterObj" Height="200px" Width="600px" SeparatorSize=2>
    <SplitterPanes>
        <SplitterPane Collapsible="true">
            <ContentTemplate>
                <div class="content">
                    <h3 class="h3">PARIS </h3>
                    Paris, the city of lights and love - this short guide is full of ideas for how to make the most of the romanticism...
                </div>
            </ContentTemplate>
        </SplitterPane>
        <SplitterPane Collapsible="true">
            <ContentTemplate>
                <div class="content">
                    <h3 class="h3">CAMEMBERT </h3>
                    The village in the Orne department of Normandy where the famous French cheese is originated from.
                </div>
            </ContentTemplate>
        </SplitterPane>
        <SplitterPane Collapsible="true">
            <ContentTemplate>
                <div class="content">
                    <h3 class="h3">GRENOBLE </h3>
                    The capital city of the French Alps and a major scientific center surrounded by many ski resorts, host of the Winter Olympics in 1968.
                </div>
            </ContentTemplate>
        </SplitterPane>
    </SplitterPanes>
</EjsSplitter>
<div id="button-container">
    <EjsButton @onclick="@ExpandClick"> Expand </EjsButton>
    <EjsButton @onClick="@CollapseClick"> Collapse </EjsButton>
</div>
<style>
    .content {
        padding: 10px;
    }
    #button-container {
        display: flex;
        margin: 20px 22% 40px;
    }
</style>

@code {
    EjsSplitter SplitterObj;

    private void ExpandClick(Object args)
    {
        this.SplitterObj.Expand(0);
    }

    private void CollapseClick(Object args)
    {
        this.SplitterObj.Collapse(0);
    }

}

The output will be as follows.

Expand and Collapse

Specify initial state to panes

You can render specific panes with collapsed state on page load. Specify a Boolean value to the Collapsed property to control this behavior. The following code explains how to collapse panes on rendering (the second panes renders with collapsed state).

@using Syncfusion.EJ2.Blazor
@using Syncfusion.EJ2.Blazor.Layouts

<EjsSplitter Height="200px" Width="600px" SeparatorSize=2>
    <SplitterPanes>
        <SplitterPane Collapsible="true">
            <ContentTemplate>
                <div class="content">
                    <h3 class="h3">PARIS </h3>
                    Paris, the city of lights and love - this short guide is full of ideas for how to make the most of the romanticism...
                </div>
            </ContentTemplate>
        </SplitterPane>
        <SplitterPane Collapsible="true" Collapsed="true">
            <ContentTemplate>
                <div class="content">
                    <h3 class="h3">CAMEMBERT </h3>
                    The village in the Orne department of Normandy where the famous French cheese is originated from.
                </div>
            </ContentTemplate>
        </SplitterPane>
        <SplitterPane Collapsible="true">
            <ContentTemplate>
                <div class="content">
                    <h3 class="h3">GRENOBLE </h3>
                    The capital city of the French Alps and a major scientific center surrounded by many ski resorts, host of the Winter Olympics in 1968.
                </div>
            </ContentTemplate>
        </SplitterPane>
    </SplitterPanes>
</EjsSplitter>

<style>
    .content {
        padding: 10px;
    }
</style>

The output will be as follows.

Expand and Collapse

See Also