gridviev 过滤器按两个不同的表进行过滤

发布于 2024-10-24 17:22:47 字数 328 浏览 3 评论 0原文

我的 gridview 基于两个表关系 - 表 A 具有列大小 (int),表 B 具有列 Human 和值(男人、女人)。我可以创建过滤器来过滤 A.Size = "100" 和 B.Human = "man" 并且当我为我的视图选择 sourse 时我想要这个过滤器 - 当我排序看不到时表 B 中具有值“woman”的记录,当我选择 B 来查看sourse时,当我进行筛选时,不会看到 A 中具有与“100”不同的值的记录。我可以创建这样的过滤器吗?如何创建?如果是的话 - devExpress 组件之间的过滤器视觉效果的适当表示是什么?我可以使用网格中的直接过滤器来完成此操作吗?

My gridview is based on a two-tables relation - table A with Column Size (int) and table B with column Human with values (man, woman). Can I create filter which filters A.Size = "100" and B.Human = "man" and I want this filter when i choose sourse for my view to be A - when I sort not to see records which in table B have value "woman" and when I select B for view sourse when i filter - not to see records which in A have values different from "100". Can I create such a filter and how? If yes - what would be the appropriate representation of this filter visual between devExpress's components? Can I do it with direct filter from my grid?

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

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

发布评论

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

评论(1

总攻大人 2024-10-31 17:22:47

据我了解,您的 GridControl 绑定到包含两个表的数据源。由于过滤器应用于GridView,并且每个GridView只能绑定到单个表,因此该过滤条件不能应用于GridView。因此,有两种解决方案适合您。首先,我认为最好的方法是将此过滤器应用于网格的基础数据源。
其次是基于GridView过滤的解决方案。在这种情况下,您应该对主 GridView 对象和详细信息 GridView 对象应用单独的筛选器。即主gridView应该具有以下过滤条件:

gridView1.ActiveFilterCriteria = new BinaryOperator("Size", 100);

要将过滤条件应用于详细信息GridView,请处理主GridView的MasterRowExpanded事件以获取详细信息GridView对象并应用过滤条件:

private void gridView1_MasterRowExpanded(object sender, DevExpress.XtraGrid.Views.Grid.CustomMasterRowEventArgs e) {
    GridView detailGridView = (sender as GridView).GetDetailView(e.RowHandle, e.RelationIndex);
    detailGridView.ActiveFilterCriteria = new BinaryOperator("Human", "man");
}

注意:第一个解决方案是最好的解决方案。

As far as I understand, your GridControl is bound to a datasource containing two tables. Since a filter is applied to a GridView and each GridView can only be bound to a single table, this filter condition cannot be applied to a GridView. So, there are two solutions for you. First, which I consider to be the best, is to apply this filter to the grid's underlying DataSource.
Second is the solution based on GridView's filtration. In this case, you should apply a separate filter on both master and detail GridView objects. I.e. the master gridView should have the following filter condition:

gridView1.ActiveFilterCriteria = new BinaryOperator("Size", 100);

To apply a filter condition to the detail GridView, handle the master GridView's MasterRowExpanded event to obtain the detail GridView object and apply a filter condition:

private void gridView1_MasterRowExpanded(object sender, DevExpress.XtraGrid.Views.Grid.CustomMasterRowEventArgs e) {
    GridView detailGridView = (sender as GridView).GetDetailView(e.RowHandle, e.RelationIndex);
    detailGridView.ActiveFilterCriteria = new BinaryOperator("Human", "man");
}

NOTE: the first solution is the best one.

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