基于内容区域/分辨率的自动分页 - Telerik Grid

发布于 2024-10-26 11:50:20 字数 155 浏览 4 评论 0原文

我正在尝试完成某件事,但我不确定这是否完全可能。

我有一个使用 ASP.NET MVC 的 Telerik MVC 网格。

网格的默认分页大小为 10,但是我希望能够根据用户分辨率的大小调整页面大小(行数)。这可能吗?

谢谢,

保罗

I am trying to accomplish something and I am not sure if it is completely possible.

I have a Telerik MVC Grid using ASP.NET MVC.

The default paging size for the grid is 10, however I want to be able to adjust the size the page (the number of rows) based on the size of the user's resolution. Is this possible?

Thanks,

Paul

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最冷一天 2024-11-02 11:50:20

这是绝对可能的。

我创建了一个完成相同任务的解决方案 - 但是您必须对其进行修改才能获得网格自身的正确高度(排除任何菜单/页眉/页脚等。

这些步骤应该到达那里:

首先 - 您需要向 MVC 网格添加一个“onLoad”事件:

    .ClientEvents(events =>events.OnLoad("onLoad"))

下一步 - 创建一个 Javascript 事件来处理 $(document) 中的“onLoad”。 ready():

    function onLoad(e)
    {
        //Bread and Butter will go here.
    }

最后 - 最后一步是计算网格未占用的空间(Firebug 可能会有所帮助)并对其进行修改,直到您的“公式”在大多数浏览器中都适用:

   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.

这应该根据您的窗口高度自动调整您的行数。唯一棘手的部分是使用占用的空间量计算出您自己的“公式”,然后选择一个要除以的神奇数字。

希望这有帮助!

It is definitely possible.

I created a solution that accomplishes the same thing - however you will have to tinker with it to get the proper height of your grid on it's own (excluding any menus/headers/footers etc.)

These steps should get you there:

Firstly - you will need to add an "onLoad" event to your MVC Grid:

    .ClientEvents(events =>events.OnLoad("onLoad"))

Next - Create a Javascript event to handle the "onLoad" in your $(document).ready():

    function onLoad(e)
    {
        //Bread and Butter will go here.
    }

Finally - the last step will be to calculate the space that is not taken up by the grid (Firebug can be helpful) and tinker with it until your "formula" works out in most browsers:

   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;
    }   

Formula :

$(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.

That should automatically adjust your your number of rows based on your window height.The only tricky part is figuring out your own "formula" using the amount of occupied space and then picking a magic number to divide by.

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文