how to set child table sorting property in a hierarchical grid

Hi, This is actually a continuation on my previous question. In a hierarchical grid, is that possible for me to define the sorting property for a childtable, so it will always show in a grid in a sorted way? Especially after I add new rows to the child table. Thanks a lot Chris

2 Replies

AD Administrator Syncfusion Team December 11, 2003 12:17 PM UTC

You can try handling the RowsExpanded and dynamically setting the sort order getting the proper information from the GridBoundRecordState.
private void grid_RowExpanded(object sender, GridRowEventArgs e)
{
	GridBoundRecordState rs = this.grid.Binder.GetRecordStateAtRowIndex(e.RowIndex);
	if(rs.HasChildList)
	{
		rs = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(e.RowIndex + 1);
		DataView dv = ((CurrencyManager)rs.ListManager).List as DataView;
		if(dv != null)
		{
			dv.Sort = dv.Table.Columns[1].ColumnName + " Desc";
		}
	}
}


AD Administrator Syncfusion Team December 11, 2003 01:13 PM UTC

this is a nice solution. THanks a lot >You can try handling the RowsExpanded and dynamically setting the sort order getting the proper information from the GridBoundRecordState. > >
>private void grid_RowExpanded(object sender, GridRowEventArgs e)
>{
>	GridBoundRecordState rs = this.grid.Binder.GetRecordStateAtRowIndex(e.RowIndex);
>	if(rs.HasChildList)
>	{
>		rs = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(e.RowIndex + 1);
>		DataView dv = ((CurrencyManager)rs.ListManager).List as DataView;
>		if(dv != null)
>		{
>			dv.Sort = dv.Table.Columns[1].ColumnName + " Desc";
>		}
>	}
>}
>

Loader.
Up arrow icon