1

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

4

1 回答 1

1

您可以处理第一个网格的 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
  }
}

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

于 2011-02-14T12:55:49.987 回答