當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。