简体   繁体   English

Kendo Ui窗口在相关容器中的尺寸调整问题

[英]Kendo Ui Window resize issue within relative container

I want to create a kendo ui window (KUI) widget that belongs within a container only. 我想创建仅属于容器内的kendo ui窗口(KUI)小部件。 After searching around, it seems that the widget is not supported that way. 搜索后,似乎不支持这种方式的小部件。 So I try to mimic as close as I could by assigning position: relative; overflow: auto; 因此,我尝试通过分配position: relative; overflow: auto;来尽可能地模仿position: relative; overflow: auto; position: relative; overflow: auto; to the container and here come the problem. 到容器中,问题就来了。

When I try to re-size the KUI, it's border does not align with the mouse position. 当我尝试调整KUI大小时,其边框与鼠标位置不对齐。 It seems to be the margin between the container and the window viewport (20px in the snippet below). 它似乎是容器和窗口视口之间的边距(在下面的代码段中为20px)。

My question is how can I make the margin go away or is there another approach to this. 我的问题是我如何才能使利润减少或有其他解决方法。

 $(function() { $("#myKendoUiWindow").kendoWindow({ title: "myTitle", appendTo: "#container" }); }); 
 #container { margin: 20px; border: 1px solid #CCC; width: 300px; height: 300px; overflow: auto; position: relative; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="http://kendo.cdn.telerik.com/2016.1.112/js/kendo.ui.core.min.js"></script> <link href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.default.min.css" rel="stylesheet" /> <link href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.common.min.css" rel="stylesheet" /> <div id="container"> <div id="myKendoUiWindow"></div> </div> 

Since this issue/limitation is a known one but isn't planed to be solved yet (thanks Lyubomir for the info), I think using jquery ui draggable, resizable is best work around for now. 由于此问题/限制是已知问题,但尚未计划解决(感谢Lyubomir提供此信息),我认为使用jquery ui可拖动,可调整大小是目前最好的解决方法。

 $(function() { var $w = $("#myKendoUiWindow").kendoWindow({ title: "myTitle", appendTo: "#container", resizable: false, // use jquery ui resizable draggable: false // use jquery ui draggable }).parent(); // kendoWindow wraps target element inside new one so we have to use parent $w.resizable().draggable({ cancel: ".k-window-actions .k-icon" // cancel dragging on window buttons }); // replace jquery ui 's resize icon with kendo ui's one $w.find(".ui-resizable-se").removeClass("ui-icon ui-icon-gripsmall-diagonal-se") .addClass("k-icon k-resize-se") }); 
 #container { margin: 20px; border: 1px solid #CCC; width: 300px; height: 300px; overflow: auto; position: relative; } 
 <link href="https://code.jquery.com/ui/1.12.0-beta.1/themes/smoothness/jquery-ui.css" rel="stylesheet" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.12.0-beta.1/jquery-ui.min.js"></script> <script src="http://kendo.cdn.telerik.com/2016.1.112/js/kendo.ui.core.min.js"></script> <link href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.default.min.css" rel="stylesheet" /> <link href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.common.min.css" rel="stylesheet" /> <div id="container"> <div id="myKendoUiWindow"></div> </div> 

Window widgets always reside in the body tag, so that they always appear on top of everything else on the page. 窗口小部件始终位于body标记中,因此它们始终显示在页面上所有其他内容的顶部。 If you want to define some boundaries and force a Window to be draggable only there, you can use the widget's events , check the new coordinates on drag end and move the Window manually if the user drags it to an undesired location. 如果要定义一些边界并强制窗口仅可在此处拖动,则可以使用小部件的事件 ,在拖动端检查新坐标,如果用户将窗口拖动到不希望的位置,则可以手动移动窗口。

To get Window new coordinates, you can use jQuery offset() . 要获取Window新坐标,可以使用jQuery offset()

We are experiencing the same issue with the Kendo Window. 剑道窗口也遇到同样的问题。 I have started a topic in Telerik's support forum which you can follow if you like, but they seem to think this is not a typical use case for the Window component. 我已经在Telerik的支持论坛中启动了一个主题 ,您可以根据需要选择该主题 ,但是他们似乎认为这不是Window组件的典型用例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM