当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


jQWidgets jqxDocking importLayout()用法及代码示例


jQWidgets 是一个 JavaScript 框架,用于为 PC 和移动设备制作基于 Web 的应用程序。它是一个非常强大、优化、独立于平台且得到广泛支持的框架。

jqxDocking 用于表示一个小部件来管理多个窗口以及网页的布局。指定的 jqxDocking 中的每个窗口都可以执行多项任务,例如,可以在网页周围拖动它、停靠到停靠区域、从停靠中移除、折叠到最小化状态以隐藏其内容,还可以展开以显示其内容内容。

importLayout() 方法用于从 JSON 类型的字符串导入 jqxDocking 的布局。它返回无。

用法:

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

参数:

  • JSON: 这是要导入的指定 JSON 字符串。它是字符串类型。

返回类型:该方法不返回任何值。

链接文件:下载jQWidgets从给定的链接。在 HTML 文件中,找到下载文件夹中的脚本文件。

<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>

示例 1:下面的示例说明了 jQWidgets jqxDockingimportLayout()方法。

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 importLayout() Method 
        </h3> 
        <div id="jqxdock" style="float: left;"> 
            <div style="overflow: hidden;"> 
                <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 style="overflow: hidden;"> 
                <div id="F2" style="height: 50px"> 
                    <div>Works At</div> 
                    <div>GeeksforGeeks</div> 
                </div> 
            </div> 
        </div> 
        <script type="text/javascript"> 
            $(document).ready(function () { 
                $('#jqxdock').jqxDocking({ 
                    theme: 'energublue', 
                    width: 150, 
                    mode: 'default' 
                }); 
  
                $('#jqxdock').jqxDocking( 
                    'importLayout', 
                    '{"panel0": {"F0":{"collapsed":false}},"panel1": 
                     {"F1":{"collapsed":false}}, 
                     "floating":{"F2": 
                         {"x":"100px","y":"200", 
                         "width":"200px","height":"auto", 
                         "collapsed":false}}, 
                     "orientation": "vertical"}'); 
            }); 
        </script> 
    </center> 
</body> 
  
</html>

输出:

示例 2:下面是jqxDocking的另一个例子importLayout()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 importLayout() Method 
        </h3> 
        <div id="jqxdock" style="float: left;"> 
            <div style="overflow: hidden;"> 
                <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 style="overflow: hidden;"> 
                <div id="F2" style="height: 50px"> 
                    <div>Works At</div> 
                    <div>GeeksforGeeks</div> 
                </div> 
            </div> 
            <input type="button" style="float: left;" 
                   id="jqxbtn" value="Click here" /> 
            <br> 
            <div id="log"></div> 
        </div> 
        <script type="text/javascript"> 
            $(document).ready(function () { 
                $('#jqxdock').jqxDocking({ 
                    theme: 'energublue', 
                    width: 150, 
                    mode: 'default' 
                }); 
                $("#jqxbtn").jqxButton({ 
                    width: 150 
                }); 
                $("#jqxbtn").on("click", function () { 
                    var op = $('#jqxdock').jqxDocking( 
                        'importLayout', 
                        '{"panel0": {"F0":{"collapsed":false}}, 
                         "panel1": {"F1":{"collapsed":false}}, 
                         "floating":{"F2":{"x":"100px","y":"200", 
                              "width":"200px","height":"auto", 
                              "collapsed":false}}, 
                         "orientation": "vertical"}'); 
                    if (op === null) { 
                        $('#log').text("Layout not imported!"); 
                    } 
                    else { 
                        $('#log').text("Layout imported!"); 
                    } 
                }); 
            }); 
        </script> 
    </center> 
</body> 
  
</html>

输出:

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



相关用法


注:本文由纯净天空筛选整理自nidhi1352singh大神的英文原创作品 jQWidgets jqxDocking importLayout() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。