Getting Started with EJ2 JavaScript Splitter

24 Nov 20266 minutes to read

The Essential® JS 2 for JavaScript (global script) is an ES5 formatted pure JavaScript framework that can be directly used in latest web browsers.

Setup for local environment

Refer to the following steps to set up your local environment.

Step 1: Create a root folder named my-app for your application.

Step 2: Create a my-app/resources folder to store local scripts and styles files.

Step 3: Open Visual Studio Code and create my-app/index.js and my-app/index.html files to initialize the Essential® JS 2 Splitter control.

Control Initialization

The Essential® JS 2 JavaScript controls can be initialized by using below css styles and scripts

Add Syncfusion® Splitter CSS Styles and Scripts

Include the following CSS and JavaScript files from CDN in the <head> section of the index.html file. The ej2-base script is the required dependency package for the Splitter component.

Styles(CSS):

https://unpkg.com/@syncfusion/ej2-bootstrap5.3-theme/styles/splitter/index.css

Scripts (javascript):

https://cdn.syncfusion.com/ej2/35.1.37/ej2-base/dist/global/ej2-base.min.js
https://cdn.syncfusion.com/ej2/35.1.37/ej2-layouts/dist/global/ej2-layouts.min.js

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.

<!DOCTYPE html>
  <html xmlns="http://www.w3.org/1999/xhtml">
       <head>
            <title>Essential JS 2</title>
           <link href="https://unpkg.com/@syncfusion/ej2-bootstrap5.3-theme/styles/splitter/index.css" rel="stylesheet" />
            <!-- Essential JS 2 Dashboardlayout's global script -->
            <script src="https://cdn.syncfusion.com/ej2/ej2-base/dist/global/ej2-base.min.js" type="text/javascript"></script>
            <script src="https://cdn.syncfusion.com/ej2/ej2-layouts/dist/global/ej2-layouts.min.js"
                type="text/javascript"></script>
        </head>
       <script>
        // Initialize splitter control
        var splitObj = new ej.layouts.Splitter({
            paneSettings: [
                // Content for Pane 1
                { content:'Left Pane' },

                // Content for Pane 2
                { content:'Middle Pane' },

                // Content for Pane 3
                { content:'Right Pane' }
            ],
            height: '250px'
        });
        // Render initialized splitter
        splitObj.appendTo('#splitter');
       </script>
       <body>
          <div id='container'>
              <!--element which is render as splitter-->
              <div id="splitter">
                  <!--list of splitter panes-->
                  <div></div>
                  <div></div>
                  <div></div>
              </div>
          </div>
       </body>
  </html>
// Initialize splitter control
var splitObj = new ej.layouts.Splitter({
    paneSettings: [
        // Content for Pane 1
        { content: 'Left Pane' },
        // Content for Pane 2
        { content: 'Middle Pane' },
        // Content for Pane 3
        { content: 'Right Pane' }
    ],
    height: '250px'
});

// Render initialized splitter
splitObj.appendTo('#splitter');
<!DOCTYPE html><html lang="en"><head>
    <title>Essential JS 2 Splitter </title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Essential JS 2 Uploader Component">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <link href="https://unpkg.com/@syncfusion/ej2-bootstrap5.3-theme/styles/splitter/index.css" rel="stylesheet" />
    
    
<script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>
<body>
    
    <div id="container">
        <!--element which is going to render the splitter-->
        <div id="splitter">
            <!--list of splitter panes-->
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>

<script>
var ele = document.getElementById('container');
if(ele) {
  ele.style.visibility = "visible";
}   
      </script>
<script src="index.js" type="text/javascript"></script>
</body></html>

See Also