0
我正在創建兩個radwindow對話框:父母及其子女。 家長radwindow有大小1082x630如何手動在其父rad窗上顯示子rad窗口?
兒童radwindow有大小1500x900
在父radwindow對話框,當我點擊「查看孩子對話」,其子radwindow將被顯示。
這裏的問題是子對話框的大小大於它的父對象。所以,我想調整子對話框的大小並將其顯示在其父對話框的中心。
這裏是我在JavaScript中的代碼,我用它來手動調整子對話框的大小。爲了居中對話框,我還使用了childRadWindow.left和childRadWindow.top。 但是,它不工作,因爲我的預期。子對話框不在其父級的中心中。
請參考我的預期,實際圖像和我的代碼來解決問題。
這裏是我的代碼來調整孩子手動對話框。我把它放在子對話框中* .aspx
<script type="text/javascript">
$(document).ready(function() {
resizeRWndDialog();
});
</script>
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";
}