猿问

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

我想在填充了 RowValues 列表的 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 中的所有列,但带有标题的空卡片仍在污染 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;

}

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

蝴蝶不菲
浏览 153回答 1
1回答

BIG阳

我成功地完成了这项任务。我认为最简单的答案是在 MasterRowEmpty 事件中将 e.IsEmpty Arg 设置为 true。看下面的代码:void gridView_MasterRowEmpty(object sender, MasterRowEmptyEventArgs e){&nbsp; &nbsp; GridView view = sender as GridView;&nbsp; &nbsp; if(view.GetRelationName(e.RowHandle, e.RelationIndex) == "list1")&nbsp; &nbsp;// == "Card Name"&nbsp; &nbsp; &nbsp; &nbsp; e.IsEmpty = true;}
随时随地看视频慕课网APP
我要回答