SyncFusion GridDataControl分组

时间:2012-10-24 14:37:55

标签: c# wpf syncfusion

我正在使用SyncFusion GridDataControl来显示一些数据。

网格中的行分组在一列(例如列Group

当列Group具有特定值(即null"")时,我不想使用组,因此行将始终显示且无法折叠。

有没有人知道如何做到这一点?

到目前为止,我已经联系到Loaded上的GridDataControl事件:

private void OnGridLoaded(object sender, RoutedEventArgs e)
{
    foreach ( Group group in AttributeGrid.Model.View.Groups)
    {
        if (@group.Key == null)
        {
            AttributeGrid.Model.Table.ExpandGroup(@group);
            // Do something here to hide the group?
        }
    }
}

1 个答案:

答案 0 :(得分:2)

请查看以下更新

//Use the below code to Expand the particular group based on the key
void AssociatedObject_Loaded(object sender, RoutedEventArgs e)
{
    foreach (Group group in this.AssociatedObject.Model.View.Groups)
    {
        if (group.Key.Equals(1))
            this.AssociatedObject.Model.Table.ExpandGroup(group);
    }
}

对于在运行时折叠组,

//Use the below code to cancel the Grouping for particular group based on the keu
void Table_GroupCollapsing(object sender, GroupCollapsingEventArgs args)
{
    if (args.Group.Key.Equals(1))
        args.Cancel = true;
}