使用数据分页器和数据网格获取特定成员

发布于 2024-10-12 12:14:10 字数 483 浏览 6 评论 0原文

您好,

我有一个显示 PagedCollectionView 的 DataGrid,其中包含包含的记录总数。

我们总共有大约 4220 条记录,每页显示 20 条记录,我们大约有 210 页。

现在我一直在尝试实现这一点:

当我搜索一个人时,我想让这个人显示在页面顶部,并将页面设置为靠近其所在页面的任何内容。

我设法使用 Linq 获取高于姓氏的项目 < /a> 但是 PagedCollectionview 会被这些结果覆盖。由于这会跳过通缉人员之前的所有内容,因此页数会有所不同。

所以基本上我想要的是有一个搜索字段,我可以在其中输入“Jan”。然后我希望页面跳转到 Jan 可能所在的页面(+/- 1 页更低或更高),并将“Jan”作为第一个记录。

Greetings,

I have a DataGrid showing a PagedCollectionView which has the total amount of records included.

In total we have about 4220 records, with 20 records showing per page we have about 210 pages.

Now I've been trying to implement this:

When I search for a person I want to have this person show on top of the page AND have the page set to anything that is near the page it would be on.

I managed to get the person on top using the example given in Linq Get items higher then lastname however the PagedCollectionview gets overwriten by these results. Since this skips everything before the wanted person the amount of pages differs.

So basicly what I want is to have a searchfield where I can enter "Jan". And then I want the page to jump to the page where Jan could be (+/- 1 page lower or higher) and have "Jan" as first record.

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

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

发布评论

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

评论(1

情话墙 2024-10-19 12:14:10

找到了我自己的答案。

不是以一种非常好的方式,但是,由于在任何时候都首先加载成员的总数,所以我创建了一个检查来查看当前加载的金额是否高于首次加载的总数。

例如:

if (loadOperation.TotalEntityCount >= itemCount || !string.IsNullOrEmpty(FilterText))
{
    this.ItemCount = loadOperation.TotalEntityCount;
}
else
{
    if (!DeleteMember)
    {
        pageIndex = (int)((this.ItemCount - loadOperation.TotalEntityCount) / this.PageSize);
        RaisePropertyChanged("PageIndex");
    }
    else
    {
        DeleteMember = false;
        itemCount -= 1;
    }
}

删除成员是为了确保在删除成员时它不会尝试设置页面索引,因此 TotalEntityCount 将比 itemcount 低 1。

Found my own answer.

Not in a very nice way but, since at all times firstly the total amount of members is being loaded, I created a check to see if the currently loaded amount is higher then the total amount first loaded.

Like:

if (loadOperation.TotalEntityCount >= itemCount || !string.IsNullOrEmpty(FilterText))
{
    this.ItemCount = loadOperation.TotalEntityCount;
}
else
{
    if (!DeleteMember)
    {
        pageIndex = (int)((this.ItemCount - loadOperation.TotalEntityCount) / this.PageSize);
        RaisePropertyChanged("PageIndex");
    }
    else
    {
        DeleteMember = false;
        itemCount -= 1;
    }
}

The delete member is to make sure it doesn't try to set the page index when a member is deleted and thus TotalEntityCount would be 1 lower then itemcount.

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