从 UltraGrid 获取子行

发布于 2024-10-16 15:20:19 字数 69 浏览 8 评论 0原文

我在 UltraGrid 中有主/详细信息关系。当用户单击行时,我想在新的 UltraGrid 中显示子行。我该怎么办?谢谢

I have master/details relation in UltraGrid. And I want to show child rows in new UltraGrid when user click on row. How can I do? Thanks

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

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

发布评论

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

评论(1

︶ ̄淡然 2024-10-23 15:20:19

您可以处理第一个网格的 AfterRowActivate 或 AfterRowSelected 事件,然后使用适当的数据填充第二个网格。
如果您在第二个网格中拥有所有父行的数据,您还可以适当地设置列过滤器,如下所示:

private void ugParent_AfterRowActivate(object sender, EventArgs e)
{
  if (this.ugParent.ActiveRow != null)
  {
    //either populate the grid with data specific to the current row:
    //this.ugChilds.DataSource = this.GetChildData(this.ugParent.ActiveRow);
    //or filter the grid
    object key = this.ugParent.ActiveRow.Cells["IDField"].Value;
    this.ugChilds.DisplayLayout.Bands[0].ColumnFilters["RelationField"].FilterConditions.Add(FilterComparisionOperator.Equals, key);
  }
  else
  {
    //clear Child grid if required. If you set datasource to null you will loose all layout and need to relayout the grid on next binding
  }
}

如果您使用列过滤器,请记住重用现有过滤器或在添加新过滤条件之前清除过滤条件。

You could handle the AfterRowActivate or AfterRowSelected events of the first grid and then either populate the second grid with appropriate data.
If you have data of all Parent rows in the second grid you can also set the column filter apropriatly like this:

private void ugParent_AfterRowActivate(object sender, EventArgs e)
{
  if (this.ugParent.ActiveRow != null)
  {
    //either populate the grid with data specific to the current row:
    //this.ugChilds.DataSource = this.GetChildData(this.ugParent.ActiveRow);
    //or filter the grid
    object key = this.ugParent.ActiveRow.Cells["IDField"].Value;
    this.ugChilds.DisplayLayout.Bands[0].ColumnFilters["RelationField"].FilterConditions.Add(FilterComparisionOperator.Equals, key);
  }
  else
  {
    //clear Child grid if required. If you set datasource to null you will loose all layout and need to relayout the grid on next binding
  }
}

If you use ColumnFilters remember to reuse existing filters or clear the filter conditions prior to adding new filter conditions.

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