本文介绍了如何手动在父RADwindow上显示子radwindow?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在创建两个radwindow对话框:父对象及其子对象。父RADwindow的大小为1082x630 儿童radwindow的大小为1500x900 在父radwindow对话框中,当我点击在显示子对话框按钮上,将显示其子窗口。 此处的问题是子对话框的大小大于其父级。所以,我想调整子对话框的大小并将其显示在其父对话框的中心。 这是我用于调整大小的Javascript代码手动的子对话框。为了居中对话框,我还使用了childRadWindow.left和childRadWindow.top。 但是,它不能像我预期的那样工作。子对话框不会放在其父级的中心。 请参考我预期的实际图像和我的代码来解决问题。 /> 我的预期结果: http: //i.stack.imgur.com/yWjnE.png [ ^ ] 实际结果: http: //i.stack.imgur.com/Srygu.png [ ^ ] 这是我手动调整子对话框大小的代码。我把它放在子对话框* .aspx I am creating two radwindow dialogs: a parent and its child. Parent radwindow has size 1082x630Child radwindow has size 1500x900On parent radwindow dialog, when I click on button "Show Child Dialog", its child radwindow will be shown.The problem here is the size of child dialog larger than its parent. So, I want to resize the size of child dialog and show it in the center of its parent dialog.And here is my code in Javascript that I use for resizing child dialog manually. To center child dialog, I also use childRadWindow.left and childRadWindow.top . BUT, it does not work as my expected. The child dialog does not place in the center of its parent.Please reference my expected, actual images and my code to get the problem.My expected result: http://i.stack.imgur.com/yWjnE.png[^]Actual result:http://i.stack.imgur.com/Srygu.png[^]Here is my code to resize child dialog manually. I put it on child dialog *.aspx<script type="text/javascript"> $(document).ready(function () { resizeRWndDialog(); }); function resizeRWndDialog() { var radWindows = []; var radWindow = GetRadWindow(); while (true) { if (radWindow != undefined && radWindow != null) { radWindows.push(radWindow._popupElement); radWindow = radWindow.BrowserWindow.GetRadWindow(); } else { break; } } var numsOfRadWindow = radWindows.length - 1; if (numsOfRadWindow > 0) { for (var i = numsOfRadWindow; i > 0; i--) { var parentWindow = radWindows[i]; var parentWidth = parentWindow.clientWidth; //parentWidth =1082 var parentHeight = parentWindow.clientHeight; //parentHeight = 630 var chidWindow = radWindows[i - 1]; var childWidth = chidWindow.clientWidth; //childWidth = 1500 var childHeight = chidWindow.clientHeight; //childHeight = 900 var rateMinWidth = 0, rateMinHeight = 0, rateMaxWidth = 0, rateMaxHeight = 0; if (chidWindow.style.minWidth != "") { rateMinWidth = parseInt(chidWindow.style.minWidth) / childWidth; } if (chidWindow.style.minHeight != "") { rateMinHeight = parseInt(chidWindow.style.minHeight) / childHeight; } if (chidWindow.style.maxWidth != "") { rateMaxWidth = parseInt(chidWindow.style.maxWidth) / childWidth; } if (chidWindow.style.maxHeight != "") { rateMaxHeight = parseInt(chidWindow.style.maxHeight) / childHeight; } if ((parentWidth - 40) > 0 && childWidth >= parentWidth - 40) { childWidth = parentWidth - 40; //parentWidth = 1082, childWidth = 1042 } if ((parentHeight - 80) > 0 && childHeight >= parentHeight - 80) { childHeight = parentHeight - 80; //parentHeight = 630, childHeight = 550 } setSizeRWndDialog(chidWindow.getElementsByClassName("rwTable")[0], rateMinWidth * childWidth, rateMinHeight * childHeight, rateMaxWidth * childWidth, rateMaxHeight * childHeight, childWidth, childHeight); setSizeRWndDialog(chidWindow, rateMinWidth * childWidth, rateMinHeight * childHeight, rateMaxWidth * childWidth, rateMaxHeight * childHeight, childWidth, childHeight); chidWindow.left = Math.round((parentWidth - childWidth) / 2, 0) + "px"; chidWindow.top = Math.round((parentHeight - childHeight) / 2, 0) + "px"; chidWindow.focus(); radWindows[i - 1] = chidWindow; } }}function setSizeRWndDialog(element, minWidth, minHeight, maxWidth, maxHeight, width, height) { if (minWidth != 0 && minHeight != 0) { element.style.minWidth = minWidth + "px"; element.style.minHeight = minHeight + "px"; } if (maxWidth != 0 && maxHeight != 0) { element.style.maxWidth = maxWidth + "px"; element.style.maxHeight = maxHeight + "px"; } else { element.style.maxWidth = width + "px"; element.style.maxHeight = height + "px"; } element.style.width = width + "px"; element.style.height = height + "px";} 推荐答案 function resizeRWndDialog() { //......... if (numsOfRadWindow > 0) { //........... } GetRadWindow().center(); // >> Just use this line} 这篇关于如何手动在父RADwindow上显示子radwindow?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-30 17:56