2
我想完成某些操作,但我不确定它是否完全可行。基于内容区域/分辨率的自动分页 - Telerik Grid
我有一个使用ASP.NET MVC的Telerik MVC Grid。
网格的默认分页大小为10,但我希望能够根据用户分辨率的大小调整页面大小(行数)。这可能吗?
感谢,
保罗
我想完成某些操作,但我不确定它是否完全可行。基于内容区域/分辨率的自动分页 - Telerik Grid
我有一个使用ASP.NET MVC的Telerik MVC Grid。
网格的默认分页大小为10,但我希望能够根据用户分辨率的大小调整页面大小(行数)。这可能吗?
感谢,
保罗
这是绝对可能。
我创建了一个完成同样的事情的解决方案 - 但你必须鼓捣出来,让您的网格的适当高度在它自己的(任何菜单/页眉/页脚排除等)
这些步骤应该让你有:
首先 - 你需要一个 “的onLoad” 事件添加到您的MVC网格:
.ClientEvents(events =>events.OnLoad("onLoad"))
下一页 - 创建一个JavaScript事件来处理在$了“的onLoad”(文件)。就绪():
function onLoad(e)
{
//Bread and Butter will go here.
}
最后 - 最后一步将是计算未被占用的空间网格(萤火虫能有所帮助),并用它修补,直到你的“公式”的作品出在大多数浏览器:
function onLoad(e)
{
//Gets the height of the Window. ($(window).height())
//Subracts the height of any menus/headers/footers (in this case 275)
//Then divide by our "magic number" which you will need to tinker with
//to determine how the grid looks in different browsers. (in this case 28)
var height = Math.floor(($(window).height()-275)/28);
var grid = $("#YourGrid").data("tGrid");
grid.pageSize = height;
}
公式:
$(window).height() - [Occupied Space]/[Magic Number]
[Occupied Space] - Total CSS Height of all objects above the Grid.
[Magic Number] - You will have to play with this one and try it out on
different browsers until you get the expected results.
这应该根据您的窗口高度自动调整您的行数。唯一棘手的部分是使用占用的空间量计算出您自己的“公式”,然后选择一个除以的幻数。
希望这会有所帮助!
这看起来像它会工作 - 我会给它一个镜头! – 2011-03-25 14:24:05
非常感谢!我最终把它看成是我需要的!我希望这可以帮助其他人! – 2011-03-25 15:20:06