Search results

Getting Started

This section briefly explains about how to include a simple Splitter in your ASP.NET Core application. You can refer ASP.NET Core Getting Started documentation page for introduction part part of the system requirements and configure the common specifications.

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to include the license key in your projects. Please refer to this link to know about registering Syncfusion license key in your ASP.NET Core application to use our control.

Adding TagHelpers

  • Now open _viewImports.cshtml file from the views folder and add the following namespace for control references and Tag Helper support.
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Syncfusion.EJ2

Adding ScriptManager

  • Add ScriptManager to the bottom of the layout.cshtml page. The ScriptManager used to place our control initialization script in the page.
<ej-scripts> </ej-scripts>

Adding themes

Refer the required theme file in your layout.cshtml page from wwwroot/styles folder.

    <link href="~/styles/material.css" rel="stylesheet"/>

Above referred CSS is material theme. Likewise you can refer the theme specific CSS which is present inside the styles folder in order to render splitter control with required themes. The Custom Resource Generator (CRG) is an online web tool, which can be used to generate the custom script and styles for a set of specific control. This web tool is useful to combine the required control scripts and styles in a single file.

Initialize the Splitter

  • Splitter control can be rendered with the help of ejs-splitter tag helper. Add the below code to your index.cshtml page which is present under Views/Home folder, where the splitter is initialized.

Run the application

After successful compilation of your application, simply press F5 to run the application.

The below example shows the splitter.

tagHelper
splitter.cs
@using Syncfusion.EJ2

@section ControlsSection {
   <ejs-splitter id="splitter" height="250px" width="600px">
      <e-splitter-panes>
         <e-splitter-pane content="<div></div>"></e-splitter-pane>
         <e-splitter-pane content="<div></div>"></e-splitter-pane>
         <e-splitter-pane content="<div></div>"></e-splitter-pane>
      </e-splitter-panes>
   </ejs-splitter>   
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication.Controllers
{
    public partial class SplitterController : Controller
    {
        public IActionResult Splitter()
        {
            return View();
        }
    }
}

Output be like the below.

splitter

Load content to the pane

You can load the pane contents in either HTML element or string types using content property.

For detailed information, refer to the Pane Content section.

tagHelper
content.cs
@using Syncfusion.EJ2

@section ControlsSection {
   <ejs-splitter id="splitter" height="250px" width="550px">
      <e-splitter-panes>
         <e-splitter-pane content="<div class='content'><h3 class='h3'>HTML</h3><div class='code-preview'>&lt;<span>!DOCTYPE html&gt;</span><div>&lt;<span>html&gt;</span></div><div>&lt;<span>body&gt;</span></div>&lt;<span>div</span> id='custom-image'&gt;<div style='margin-left: 5px'>&lt;<span>img</span> src='src/albert.png'&gt;</div><div>&lt;<span>div</span>&gt;</div><div>&lt;<span>/body&gt;</span></div><div>&lt;<span>/html&gt;</span></div></div></div>"></e-splitter-pane>
         <e-splitter-pane content="<div class='content'><h3 class='h3'>CSS</h3><div class='code-preview'><span>img {</span><div id='code-text'>margin:<span>0 auto;</span></div><div id='code-text'>display:<span>flex;</span></div><div id='code-text'>height:<span>70px;</span></div><span>   }</span></div></div>"></e-splitter-pane>
         <e-splitter-pane content="<div class='content'><h3 class='h3'>JavaScript</h3><div class='code-preview'><span>var</span> image = document.getElementById('custom-image');<div>image.addEventListener('click', function() {</div><div style='padding-left: 20px;'>// Code block for click action</div><span> }</span></div></div>"></e-splitter-pane>
      </e-splitter-panes>
   </ejs-splitter>   
}

<style>
    #code-text {
        margin-left: 5px;
    }
    .code-preview {
        margin-top: 15px;
        font-size: 12px;
    }
    .h3 {
        font-size: 14px;
        margin: 4px;
    }
    .content {
        padding: 12px;
    }
    .splitter-image {
        margin: 0 auto;
        display: flex;
        height: 115px;
        margin-top: 10px;
    }
</style>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication.Controllers
{
    public partial class SplitterController : Controller
    {
        public IActionResult LoadContent()
        {
            return View();
        }
    }
}

Output be like the below.

Loading content to the panes

Configure pane size

You can specify the size to each pane using size property. It accepts pane values in percentage and pixel types.

In case of pane size is not declared, panes will equally share the sizes automatically.

For Horizontal orientation, panes will share the total width. For Vertical orientation, panes will share the total height.

tagHelper
panesize.cs
@using Syncfusion.EJ2

@section ControlsSection {
   <ejs-splitter id="splitter" height="250px" width="550px">
      <e-splitter-panes>
         <e-splitter-pane size="40%" content="<div class='content'><h3 class='h3'>HTML</h3><div class='code-preview'>&lt;<span>!DOCTYPE html&gt;</span><div>&lt;<span>html&gt;</span></div><div>&lt;<span>body&gt;</span></div>&lt;<span>div</span> id='custom-image'&gt;<div style='margin-left: 5px'>&lt;<span>img</span> src='src/albert.png'&gt;</div><div>&lt;<span>div</span>&gt;</div><div>&lt;<span>/body&gt;</span></div><div>&lt;<span>/html&gt;</span></div></div></div>"></e-splitter-pane>
         <e-splitter-pane size="20%" content="<div class='content'><h3 class='h3'>CSS</h3><div class='code-preview'><span>img {</span><div id='code-text'>margin:<span>0 auto;</span></div><div id='code-text'>display:<span>flex;</span></div><div id='code-text'>height:<span>70px;</span></div><span>   }</span></div></div>"></e-splitter-pane>
         <e-splitter-pane size="40%" content="<div class='content'><h3 class='h3'>JavaScript</h3><div class='code-preview'><span>var</span> image = document.getElementById('custom-image');<div>image.addEventListener('click', function() {</div><div style='padding-left: 20px;'>// Code block for click action</div><span> }</span></div></div>"></e-splitter-pane>
      </e-splitter-panes>
   </ejs-splitter>   
}

<style>
    #code-text {
        margin-left: 5px;
    }
    .code-preview {
        margin-top: 15px;
        font-size: 12px;
    }
    .h3 {
        font-size: 14px;
        margin: 4px;
    }
    .content {
        padding: 12px;
    }
    .splitter-image {
        margin: 0 auto;
        display: flex;
        height: 115px;
        margin-top: 10px;
    }
</style>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication.Controllers
{
    public partial class SplitterController : Controller
    {
        public IActionResult PaneSize()
        {
            return View();
        }
    }
}

Resizable panes

Splitter allows you to change the pane dimensions by resizing the panes. By default, all the panes are resizable. You can disable the resize by using resizable property in each pane settings.

tagHelper
resizable.cs
@using Syncfusion.EJ2

@section ControlsSection {
   <ejs-splitter id="splitter" height="250px" width="550px">
      <e-splitter-panes>
         <e-splitter-pane size="40%" min="30px" resizable="false" content="<div class='content'><h3 class='h3'>HTML</h3><div class='code-preview'>&lt;<span>!DOCTYPE html&gt;</span><div>&lt;<span>html&gt;</span></div><div>&lt;<span>body&gt;</span></div>&lt;<span>div</span> id='custom-image'&gt;<div style='margin-left: 5px'>&lt;<span>img</span> src='src/albert.png'&gt;</div><div>&lt;<span>div</span>&gt;</div><div>&lt;<span>/body&gt;</span></div><div>&lt;<span>/html&gt;</span></div></div></div>"></e-splitter-pane>
         <e-splitter-pane size="20%" min="15%" content="<div class='content'><h3 class='h3'>CSS</h3><div class='code-preview'><span>img {</span><div id='code-text'>margin:<span>0 auto;</span></div><div id='code-text'>display:<span>flex;</span></div><div id='code-text'>height:<span>70px;</span></div><span>   }</span></div></div>"></e-splitter-pane>
         <e-splitter-pane size="40%" content="<div class='content'><h3 class='h3'>JavaScript</h3><div class='code-preview'><span>var</span> image = document.getElementById('custom-image');<div>image.addEventListener('click', function() {</div><div style='padding-left: 20px;'>// Code block for click action</div><span> }</span></div></div>"></e-splitter-pane>
      </e-splitter-panes>
   </ejs-splitter>   
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication.Controllers
{
    public partial class SplitterController : Controller
    {
        public IActionResult Resizable()
        {
            return View();
        }
    }
}

Output be like the below.

Resizable panes

Set minimum and maximum pane sizes

Splitter allows you to set the minimum and maximum sizes for each pane. Resize will happens up to the minimum and maximum values only. It will accepts the size in both percentage and pixel formats.

tagHelper
panesize.cs
@using Syncfusion.EJ2

@section ControlsSection {
   <ejs-splitter id="splitter" height="250px" width="550px">
      <e-splitter-panes>
         <e-splitter-pane size="40%" min="30px" max="60%" resizable="false" content="<div class='content'><h3 class='h3'>HTML</h3><div class='code-preview'>&lt;<span>!DOCTYPE html&gt;</span><div>&lt;<span>html&gt;</span></div><div>&lt;<span>body&gt;</span></div>&lt;<span>div</span> id='custom-image'&gt;<div style='margin-left: 5px'>&lt;<span>img</span> src='src/albert.png'&gt;</div><div>&lt;<span>div</span>&gt;</div><div>&lt;<span>/body&gt;</span></div><div>&lt;<span>/html&gt;</span></div></div></div>"></e-splitter-pane>
         <e-splitter-pane size="20%" min="15%" max="40%" content="<div class='content'><h3 class='h3'>CSS</h3><div class='code-preview'><span>img {</span><div id='code-text'>margin:<span>0 auto;</span></div><div id='code-text'>display:<span>flex;</span></div><div id='code-text'>height:<span>70px;</span></div><span>   }</span></div></div>"></e-splitter-pane>
         <e-splitter-pane size="40%" content="<div class='content'><h3 class='h3'>JavaScript</h3><div class='code-preview'><span>var</span> image = document.getElementById('custom-image');<div>image.addEventListener('click', function() {</div><div style='padding-left: 20px;'>// Code block for click action</div><span> }</span></div></div>"></e-splitter-pane>
      </e-splitter-panes>
   </ejs-splitter>
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication.Controllers
{
    public partial class SplitterController : Controller
    {
        public IActionResult PaneSize()
        {
            return View();
        }
    }
}

Orientation

Splitter supports both Horizontal and Vertical orientation for the panes. By default, it will be rendered in Horizontal orientation. You can change it by using orientation property.

tagHelper
orientation.cs
@using Syncfusion.EJ2

@section ControlsSection {
   <ejs-splitter id="splitter" height="200px" width="550px" orientation="Vertical">
      <e-splitter-panes>
         <e-splitter-pane size="50%" min="30%" content="<div class='content'> Top pane</div>"></e-splitter-pane>
         <e-splitter-pane size="50%" min="30%" content="<div class='content'> Bottom pane</div>"></e-splitter-pane>
      </e-splitter-panes>
   </ejs-splitter>
}

<style>
    .content {
        justify-content: center;
        text-align: center;
        align-items: center;
        height: 100%;
        display: flex;
    }
</style>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication.Controllers
{
    public partial class SplitterController : Controller
    {
        public IActionResult Orientation()
        {
            return View();
        }
    }
}

Output be like the below.

Orientation

Nested splitter

Splitter provides support to render the nested pane to achieve the complex layouts. You can render the nested splitter using the <div> element provided for parent splitter.

Also you can render the nested splitter using direct child of the splitter pane. For this, nested splitter should have 100% width and height to match with the parent pane dimensions.

tagHelper
nested.cs
@using Syncfusion.EJ2

@{

    var pane4Content = "<div class='content'><h3 class='h3'>Preview of sample</h3><div class='splitter-image'><img class='img1' src='https://ej2.syncfusion.com/demos/src/listview/images/albert.png' style='width: 20%;margin: 0 auto;'></div></div>";
}

@section ControlsSection {
    <div class="pane1">
        <ejs-splitter id="outerSplitter" height="430px" width="600px" orientation="Vertical" created="onLoad">
            <e-splitter-panes>
                <e-splitter-pane size="50%" min="30%"></e-splitter-pane>
                <e-splitter-pane size="50%" min="30%"></e-splitter-pane>
                <e-splitter-pane content=@pane4Content></e-splitter-pane>
            </e-splitter-panes>
        </ejs-splitter>
    </div>
}

<style>
    .h3 {
        font-size: 14px;
        margin: 4px;
    }
    .content {
        padding: 12px;
    }
    .splitter-image {
        margin: 0 auto;
        display: flex;
        height: 115px;
        margin-top: 10px;
    }
    #code-text {
        margin-left: 5px;
    }
    .code-preview {
        margin-top: 15px;
        font-size: 12px;
    }
</style>

@section PreScripts {
    <script>

        var pane1Content = "<div><div class='content'><h3 class='h3'>HTML</h3><div class='code-preview'>&lt;<span>!DOCTYPE html></span><div>&lt;<span>html></span></div>" +
            "<div>&lt;<span>body></span></div>&lt;<span>div</span> id='custom-image'><div style='margin-left: 5px'>&lt;<span>img</span> src='src/albert.png'></div>" +
            "<div>&lt;<span>div</span>&gt;</div><div>&lt;<span>/body></span></div><div>&lt;<span>/html></span></div></div></div></div>";

        var pane2Content = "<div><div class='content'><h3 class='h3'>CSS</h3><div class='code-preview'><span>img {</span><div id='code-text'>margin:<span>0 auto;</span></div>" +
            "<div id='code-text'>display:<span>flex;</span></div><div id='code-text'>height:<span>70px;</span></div><span>}</span></div></div></div>";

        var pane3Content = "<div><div class='content'><h3 class='h3'>JavaScript</h3><div class='code-preview'><span>var </span>" +
            "image = document.getElementById('custom-image');<div>image.addEventListener('click', function() {</div>" +
            "<div style='padding-left: 20px;'>// Code block for click action</div><span> }</span></div></div></div>";


        function onLoad() {
            document.getElementById('outerSplitter').querySelector('.e-pane-vertical').setAttribute('id', 'Innersplitter');
            var splitterObj = new ej.layouts.Splitter({
                height: '250px',
                paneSettings: [
                    {
                        size: '40%', min: '30px', resizable : false, content: pane1Content
                    },
                    {
                        size: '20%', min: '15%', content: pane2Content
                    },
                    {
                        size: '40%' content: pane3Content
                    }
                ],
                width: '100%'
            });
            splitterObj.appendTo('#Innersplitter');
    }
    </script>
 }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication.Controllers
{
    public partial class SplitterController : Controller
    {
        public IActionResult NestedSplitter()
        {
            return View();
        }
    }
}

Output be like the below.

Nested splitter