Unbound Grid
How to populate a group row with child rows dynamically when it expands or collapses?
You can do this in the handler of the grid control's GroupRowExpansionChanging event. Don't forget to clear previously created child rows before you start adding child rows. The following sample shows how it may be done. [C#]
private void unboundGridControl1_GroupRowExpansionChanging(
object sender, Elegant.Grid.GroupRowEventArgs e)
{
GroupRow groupRow = e.GroupRow;
if(groupRow.Expanded)
return;
// Proceed only if the group row is expanding.
groupRow.Rows.Clear();
string time = DateTime.Now.ToString();
groupRow.Rows.Add(unboundGridControl1.NewDataRow(new string[] {"1", time}));
groupRow.Rows.Add(unboundGridControl1.NewDataRow(new string[] {"2", time}));
groupRow.Rows.Add(unboundGridControl1.NewDataRow(new string[] {"3", time}));
groupRow.Rows.Add(unboundGridControl1.NewDataRow(new string[] {"4", time}));
}
[VB.NET]
Private Sub unboundGridControl1_GroupRowExpansionChanging( _
ByVal sender As Object, ByVal e As Elegant.Grid.GroupRowEventArgs)
Dim groupRow As GroupRow = e.GroupRow
If groupRow.Expanded Then
Return
End If
' Proceed only if the group row is expanding.
groupRow.Rows.Clear()
Dim time As String = DateTime.Now.ToString()
groupRow.Rows.Add(unboundGridControl1.NewDataRow( _
New String() {"1", time}))
groupRow.Rows.Add(unboundGridControl1.NewDataRow( _
New String() {"2", time}))
groupRow.Rows.Add(unboundGridControl1.NewDataRow( _
New String() {"3", time}))
groupRow.Rows.Add(unboundGridControl1.NewDataRow( _
New String() {"4", time}))
End Sub
If you have any questions, please visit our forum or contact our technical support team at support@prof-uis.com.
|