我有一个jQuery对话框。我在对话框中显示一个asp.net gridview。 我想根据网格视图的大小来改变对话框的大小。动态更改jQuery UI对话框的大小
有一个按钮,当点击它时会显示对话框。
我想设置对话框的大小,使gridview完全适合它。
I have my javascript code below :
$("#ViewModalPopup").dialog({
height: 800px,
scrollable: true,
width: 800,
modal: true
});
这里#ViewModalPopup是包含模式弹出窗口的div。
我试图实现下面的逻辑来调整对话的基础上,div的尺寸高度:
var maxHeight = 600;
var currentHeight = $('#ViewModalPopup').height();
if (currentHeight < maxHeight) {
var desiredHeight = currentHeight
}
else
{
var desiredHeight = maxHeight;
}
$("#ViewModalPopup").dialog({
height: desiredheight,
scrollable: true,
width: 800,
modal: true
});
但它不工作作为
var currentHeight = $('#ViewModalPopup').height();
是走出来是从第二个按钮点击向下空。
有什么办法可以动态地改变对话框的大小吗?
当你没有设置高度在所有会发生什么? –
嗨Jason P!有时gridview有很多行,从屏幕的顶部延伸到底部。设置高度并放置滚动条有助于限制对话框的高度。 – CodeNinja
所以你基本上想要一个最大高度。你有没有尝试使用css在对话框div上设置'max-height'? –