利用kendo ui window建立自己的promise window,kendoui

來源:互聯網
上載者:User

利用kendo ui window建立自己的promise window,kendoui

建立一個appdialog.js檔案,代碼如下

var contexts = {};var dialogCount = 0;var app = {    getDialog: function (obj) {        if (obj) {            return obj.__dialog__;        }        return undefined;    },    close: function (obj) {        var theDialog = this.getDialog(obj);        if (theDialog) {            var rest = Array.prototype.slice.call(arguments, 1);            theDialog.close.apply(theDialog, rest);        }    },    initOption: function (obj) {        var kendowindOption = {            actions: ["Pin", "Refresh", "Maximize", "Minimize", "Close"],            draggable: true,            pinned: true,            height: "450px",            modal: true,            resizable: true,            title: "新增",            width: "700px"        };        if (obj) {            if (obj.actions) {                kendowindOption.actions = obj.actions;            }            if (obj.height) {                kendowindOption.height = obj.height;            }            if (obj.width) {                kendowindOption.width = obj.width;            }            if (obj.title) {                kendowindOption.title = obj.title;            }        }        return kendowindOption;    },    showDialog: function (obj) {        var dialogid = "dialog" + dialogCount;        var dialogFilter = "#" + dialogid;        if ($(dialogFilter) == undefined || $(dialogFilter).length === 0)            $("body").append('<div id="' + dialogid + '"></div>');        var instance = $(dialogFilter).data("kendoWindow");        if (instance == undefined) {            var kendowindOption = this.initOption(obj);            $(dialogFilter).kendoWindow(kendowindOption);        }        var dfd = $.Deferred();        instance = $(dialogFilter).data("kendoWindow");        instance.__dialog__ = {            close: function () {                dialogCount = dialogCount - 1;                delete instance.__dialog__;                instance.close();                $(dialogFilter).remove();                var args = arguments;                if (args.length === 0) {                    dfd.resolve();                } else if (args.length === 1) {                    dfd.resolve(args[0]);                } else {                    dfd.resolve.apply(dfd, args);                }            }        };        dialogCount = dialogCount + 1;        instance.center();        var url = obj.url;        instance.refresh({            url: url        });        instance.open();        return dfd.promise();    }};

建立一個index.html 頁面

  

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>    <style>        html {            font-size: 12px;            font-family: Arial, Helvetica, sans-serif;        }    </style>    <title></title>    <link href="http://cdn.kendostatic.com/2014.2.716/styles/kendo.common.min.css" rel="stylesheet" />    <link href="http://cdn.kendostatic.com/2014.2.716/styles/kendo.default.min.css" rel="stylesheet" />    <link href="http://cdn.kendostatic.com/2014.2.716/styles/kendo.dataviz.min.css" rel="stylesheet" />    <link href="http://cdn.kendostatic.com/2014.2.716/styles/kendo.dataviz.default.min.css" rel="stylesheet" />    <script src="http://cdn.kendostatic.com/2014.2.716/js/jquery.min.js"></script>    <script src="http://cdn.kendostatic.com/2014.2.716/js/angular.min.js"></script>    <script src="http://cdn.kendostatic.com/2014.2.716/js/kendo.all.min.js"></script>    <script src="appdialog.js"></script></head><body>    <button id="open">開啟視窗</button>    <script>        $(function () {            initOpenBtn();        });        function initOpenBtn() {            $("#open").click(function () {                var obj = { url: "page2.html" };                app.showDialog(obj).then(function (result) {                    if (result) {                        alert(result);                        console.log(result);                    }                });            });        }    </script></body></html>
建立page2.html 頁面

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>    <title></title></head><body>    <button id="save">關閉</button>    <script>        $("#save").click(function () {            var result = "sfasfasdf";            app.close($("#save").closest(".k-window-content").data("kendoWindow"), result);        });    </script></body></html>

點擊開啟按鈕效果如下:



點擊關閉按鈕




   




這個功能只是做了大概的,需要繼續完善。kendo ui 中promise操作沒有設計好。感覺用起來不是很爽


kendo ui是什?我下下來的源碼都是html、css、js的東西,教

Kendo UI使用者介面是利用WEB中最新的技術HTML5、CSS3、JavaScript而建立的
 
kendo ui畫折線圖時可以有2個X軸

假設時間A1:A5,B1中濃度:B5,單擊“插入” - >“圖表” - >“折線圖”,“下一步”,“資料區”;選擇(或直接輸入):!
= Sheet1中$ B $ 1:在“分類(X)軸標籤”,選擇(或輸入)$ B $ 5

點“系列”:

=工作表Sheet1 $ A $ 1: ! $ A $ 5
“完成”就可以了。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.