Open In App

jQWidgets jqxDocking exportLayout() Method

Last Updated : 16 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

jQWidgets is a JavaScript framework for making web-based applications for PC and mobile devices. It is a very powerful, optimized, platform-independent, and widely supported framework. The jqxDocking is used for representing a widget to manage multiple windows and also the layout of a web page. Each window in the specified jqxDocking can do multiple tasks such as, it can be dragged around the web page, docked into docking zones, removed from the docking, collapsed into a minimized state for hiding its content, and also can be expanded for displaying its content.

The exportLayout() method is used for exporting the displayed jqxDocking’s layout to a string that is of type JSON. It returns a String.

Syntax:

$('#jqxDocking').jqxDocking('exportLayout');

 

Linked Files: Download jQWidgets from the given link. In the HTML file, locate the script files in the downloaded folder.

<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<script type=”text/javascript” src=”scripts/jquery.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxdocking.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxwindow.js”></script>

Example 1: The below example illustrates the jQWidgets jqxDocking exportLayout() method.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <link rel="stylesheet"
        href="jqwidgets/styles/jqx.base.css"
        type="text/css"/>
    <script type="text/javascript"
            src="scripts/jquery.js">
    </script>
    <script type="text/javascript"
            src="jqwidgets/jqxcore.js">
    </script>
    <script type="text/javascript"
            src="jqwidgets/jqxdocking.js">
    </script>
    <script type="text/javascript"
            src="jqwidgets/jqxwindow.js">
    </script>
</head>
<body>
    <center>
        <h1 style="color:green;">
            GeeksforGeeks
        </h1>
        <h3>
            jQWidgets jqxDocking exportLayout() Method
        </h3>
        <div id="jqx_Docking" 
             style="margin:25px;" 
             align="left">
            <div>
                <div id="First_Window">
                    <div>First Window</div>
                    <div>
                        <h8>Content for the first window</h8>
                        <ul>
                            <li>GFG</li>
                            <li>CSE</li>
                        </ul>
                    </div>
                </div>
                <div id="Second_Window">
                    <div> Second Window</div>
                    <div>
                        <h8>Content for the second window</h8>
                        <ul>
                            <li>GeeksforGeeks</li>
                            <li>CSE</li>
                        </ul>
                    </div>
                </div>
            </div>
            <div>
                <input type="btn" 
                       value="Exp_layout" 
                       id="expBtn" />
                <br />
                <textarea id="exp_Output" 
                          rows="4" 
                          cols="36">
                </textarea>
            </div>
        </div>
        <script type="text/javascript">
            $(document).ready(function () {
                $("#jqx_Docking").jqxDocking({
                    width: 300,
                    height: 400,
                    orientation: 'vertical',
                    mode: 'default',
                });
                $("#expBtn").jqxButton({
                    width: 100,
                });
                $('#expBtn').click(function () {
                    $('#exp_Output').val($(
                        '#jqx_Docking').jqxDocking('exportLayout')
                    );
                });
            });
        </script>
    </center>
</body>
  
</html>


Output:

 

Example 2: The following is another example of the jqxDocking exportLayout() method in jQWidgets.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <link rel="stylesheet"
        href="jqwidgets/styles/jqx.base.css"
        type="text/css"/>
    <script type="text/javascript"
            src="scripts/jquery.js">
    </script>
    <script type="text/javascript"
            src="jqwidgets/jqxcore.js">
    </script>
    <script type="text/javascript"
            src="jqwidgets/jqxdocking.js">
    </script>
    <script type="text/javascript"
            src="jqwidgets/jqxwindow.js">
    </script>
</head>
<body>
    <center>
        <h1 style="color:green;">
            GeeksforGeeks
        </h1>
        <h3>
            jQWidgets jqxDocking exportLayout() Method
        </h3>
        <div id="jqx_Docking" style="margin:25px;" align="left">
            <div>
                <div id="First_Window">
                    <div>First Window</div>
                    <div>
                        <h8>Content for the first window</h8>
                        <ul>
                            <li>GFG</li>
                            <li>CSE</li>
                        </ul>
                    </div>
                </div>
                <div id="Second_Window">
                    <div> Second Window</div>
                    <div>
                        <h8>Content for the second window</h8>
                        <ul>
                            <li>GeeksforGeeks</li>
                            <li>CSE</li>
                        </ul>
                    </div>
                </div>
            </div>
            <div>
                <input type="btn" value="Exp_layout" id="expBtn" />
                <br />
                <textarea id="exp_Output" rows="4" cols="36">
                </textarea>
            </div>
            <br>
            <center>
                <div id="log"></div>
            </center>
        </div>
        <script type="text/javascript">
            $(document).ready(function () {
                $("#jqx_Docking").jqxDocking({
                    width: 300,
                    height: 400,
                    orientation: 'vertical',
                    mode: 'default',
                });
                $("#expBtn").jqxButton({
                    width: 100,
                });
                $('#expBtn').click(function () {
                    var op = $('#exp_Output').val($(
                        '#jqx_Docking').jqxDocking('exportLayout'));
                    if (op != null) {
                        $('#log').text("Layout exported!");
                    }
                    else {
                        $('#log').text("Layout not exported!");
                    }
                });
            });
        </script>
    </center>
</body>
  
</html>


Output:

 

Reference: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxdocking/jquery-docking-api.htm?search=



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads