开发者

Devexpress - How do I base a Gridcontrol's data on the sorted/filtered data from another GridControl?

I have two GridControls on my form. One is a fairly large dataset, including a column named Score. I want my other GridControl to show a subset of this (e.g. Top 3 and Bottom 3 based on the values of Score).

How can I best accompli开发者_如何学Pythonsh this? If it were the same GridControl I imagine I could just use a different view, but since it's completely separate, should I just grab a copy of the view, filter/sort the data and display it as a new dataset? Or is there a way to link my second GridControl's data to my first's?

edit: I could do grid2.datasource = grid1.datasource and go from there. There won't be any dynamic updates to the table so maybe this is the way to go?


I would use the following approach:

1) create a new DataView, filter it based on your approach and set the second gridControl's DataSource to this DataView;

OR

2) set the DataSource property of the second GridControl to the same value and filter the corresponding GridView.


No need to create a new DataView. Check out the gridview's CustomRowFilter event.

Use e.ListSourceRow to get the row in the datatable.

So if suppose you want rows with value > 25 to be displayed and the rest hidden

gridView_CustomRowFilter(object sender, RowFilterEventArgs e)
{
      if(dataset.datatable[e.ListSourceRow]["ColumnName"] < 25)
      {  
          e.visible = false;
          e.handled = true;
      }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜