计算 CurrentGroup 的公式是什么
尝试找出一个方程式来获取页面当前所在的组(如果它们按如下方式分组)。
变量:
PageSize = 5
PageIndex = 21
GroupSize = 5
TotalItems = 1000
CurrentPage = PageIndex + 1
查找:
**CurrentGroup = ?**
如果有 1000 个项目,并且组大小为 5,则有 200 个组(TotalItems / GroupSize)。 这意味着 CurrentPage 22 必须位于第 5 组
Group 1: 1 2 3 4 5
Group 2: 6 7 8 9 10
Group 3: 11 12 13 14 15
Group 4: 16 17 18 19 20
Group 5: 21 22 23 24 25
Trying to figure out an equation to get the current group a page would be in if they were grouped like below.
Variables:
PageSize = 5
PageIndex = 21
GroupSize = 5
TotalItems = 1000
CurrentPage = PageIndex + 1
Find:
**CurrentGroup = ?**
If there are 1000 items and you have a group size of 5 then there are 200 groups (TotalItems / GroupSize). This means that CurrentPage 22 must land in group 5
Group 1: 1 2 3 4 5
Group 2: 6 7 8 9 10
Group 3: 11 12 13 14 15
Group 4: 16 17 18 19 20
Group 5: 21 22 23 24 25
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
配方
测试
Formula
Test
我认为这就是您要问的 -
假设整数数学:
Page 是您要查找的页面
pageIndex 是它在目标页面
组 上的位置 em> 是基于 GroupSize 的实际组。
本质上,您只是添加了另一个级别的分页,因此与分页相同的数学原理。
I think this is what you were asking --
Assumes integer math:
Page is the page you're seeking
pageIndex is it's position on the destination page
group is the actual group it fits in based on GroupSize
In essence, you're just adding another level of paging so the same math works as paging.