Open In App

jQWidgets jqxDocking setWindowPosition() Method

Last Updated : 10 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 setWindowPosition() method is used to move the displayed jqxDocking’s window to a particular position in floating mode. It returns None.

Syntax:

$('#jqxDocking').jqxDocking('setWindowPosition', 'windowId', top, left);

Parameters:

  • windowId: It is the stated window’s id which is of type string.
  • top: It is the stated top position which is of type number.
  • left: It is the stated left position which is of type number.

Return type: The method doesn’t return any value.

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 setWindowPosition() 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 setWindowPosition() Method
        </h3>
        <div id="jqxdock" style="float: left;">
            <div>
                <div id="F0" style="height: 50px">
                    <div>Name</div>
                    <div>Nidhi Singh</div>
                </div>
                <div id="F1" style="height: 50px">
                    <div>Subject</div>
                    <div>Data Structure</div>
                </div>
            </div>
            <div>
                <div id="F2">
                    <div>Works At</div>
                    <div>GeeksforGeeks</div>
                </div>
            </div>
        </div>
        <script type="text/javascript">
            $(document).ready(function () {
                $('#jqxdock').jqxDocking({
                    theme: 'energublue',
                    width: 200,
                    windowsMode: {
                        'F0': 'docked',
                        'F0': 'docked',
                        'F2': 'floating'
                    }
                });
                $('#jqxdock').jqxDocking(
                    'setWindowPosition', 'F2', 150, 150);
            });
        </script>
    </center>
</body>
  
</html>


Output:

jQWidgets jqxDocking setWindowPosition() Method

jQWidgets jqxDocking setWindowPosition() Method

Example 2: The following is another example of the jqxDocking setWindowPosition() 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 setWindowPosition() Method
        </h3>
        <div id="jqxdock" style="float: left;">
            <div>
                <div id="F0" style="height: 50px">
                    <div>Name</div>
                    <div>Nidhi Singh</div>
                </div>
                <div id="F1" style="height: 50px">
                    <div>Subject</div>
                    <div>Data Structure</div>
                </div>
            </div>
            <div>
                <div id="F2">
                    <div>Works At</div>
                    <div>GeeksforGeeks</div>
                </div>
            </div>
            <input type="button" id="jqxbtn" value="Click here" />
            <br>
            <div id="log"></div>
        </div>
        <script type="text/javascript">
            $(document).ready(function () {
                $('#jqxdock').jqxDocking({
                    theme: 'energublue',
                    width: 200,
                    windowsMode: {
                        'F0': 'docked',
                        'F0': 'docked',
                        'F2': 'floating'
                    }
                });
                $("#jqxbtn").jqxButton({
                    width: 200
                });
                $("#jqxbtn").on("click", function () {
                    var op = $('#jqxdock').jqxDocking(
                        'setWindowPosition', 'F2', 150, 150);
                    if (op === null) {
                        $('#log').text("window position not set!");
                    }
                    else {
                        $('#log').text("Position set!");
                    }
                });
            });                
        </script>
    </center>
</body>
  
</html>


Output:

jQWidgets jqxDocking setWindowPosition() Method

jQWidgets jqxDocking setWindowPosition() Method

Reference: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxdocking/jquery-docking-api.htm?search=#:~:text=Method-,setWindowPosition,-Method



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads