Get child rows from UltraGrid

2.6k Views Asked by At

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

1

There are 1 best solutions below

0
On

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.