如何隐藏DevExpress Master Detail DataGrid中的一些卡片?

How to hide some cards in DevExpress Master Detail DataGrid?

我想在填充有行值列表的 DataGrid 中显示一些(但不是全部)数据:

public class RowValue 
{
    public int id;
    public string name;
    public List<A> list1;
    public List<B> list2;
}

public class A
{
    public int id;
    public string val1;
    public string val2;
    ...
}

public class B
{
    public int id;
    public string val1;
    public string val2;
    ...
}

当我在 Master-Detail DataGrid 中展开一行时,我看到两张卡片显示每个列表(list1 和 list2)的行。我想在我的 DataGrid 中隐藏 list1。目前我可以隐藏 list1 中的所有列,但是带有 header 的空卡片仍在污染 GridView。

void gridView_MasterRowExpand(object sender, CustomMasterRowEventArgs e)
{
   var masterView = sender as GridView;
   GridView detailView = masterView?.GetDetailView(e.RowHandle, e.RelationIndex) as GridView;
   if(detailView == null) return;

   //disabling Columns
   if(detailView.LevelName == "list1")
       foreach(var column in detailView.Columns)
           column.Visible = false;
}

为了说明我的问题,我附上了已删除所有列的卡片图片。

Empty card I wish to remove from view.

我成功地完成了这个任务。我认为最简单的答案是在 MasterRowEmpty 事件中将 e.IsEmpty Arg 设置为 true。请参阅下面的代码:

void gridView_MasterRowEmpty(object sender, MasterRowEmptyEventArgs e)
{
    GridView view = sender as GridView;
    if(view.GetRelationName(e.RowHandle, e.RelationIndex) == "list1")   // == "Card Name"
        e.IsEmpty = true;
}