Filtering a whole DataSet, including relations RRS feed

  • Question

  • Hello,

    Before, sorry for my poor english.. 

    I'm working on a project, which contains a lot of DataGrids binding to one DataSet (strong typed, relations, keys, etc.).
    The DataSet must be filtered with differents conditions according to the needs of the user.

    So I have differents DataViewmanager working together on the same DataSet, and depends the window open, they will filter the data differently.

    For exemple, I can have 3 DataGrids, (GridMaster, GridDetails, GridSubDetails) on the same window.

    GridMaster filled by Dates,
    GridDetails filled by Orders,
    GridSubDetails filled by OrderLines.

    I would like to add a column in the GridDetails to count the filtered rows child of the data "OrderLines".
    So, if the count = 0, I can hide the parent. Same for the GridMaster, if no orders are visible after filter, I can hide the according Date.

    Do you see ?

    Here, a sample code (I need the line code for counting filtered Orderlines rows) :

            _dataprovider.DataSet.Tables["Dates"].Columns["ChildCount"].Expression = "SUM(Child.ChildCount)"
                _dataprovider.DataSet.Tables["Tours"].Columns["ChildCount"].Expression = "SUM(Child.ChildCount)"
                _dataprovider.DataSet.Tables["Orders"].Columns["ChildCount"].Expression = CODE MISSING HERE !!! 
                DataViewManager _dvm = App.DataProvider.DataSet.DefaultViewManager; 
                _dvm.DataViewSettings["Dates"].RowFilter = "ChildCount > 0"
                _dvm.DataViewSettings["Tours"].RowFilter = "ChildCount > 0"
                _dvm.DataViewSettings["Orders"].RowFilter = "ChildCount > 0"
                _dvm.DataViewSettings["OrderLines"].RowFilter = "(QuantityOpen <> 0 AND DocType = 'ORDR')"
                _dataView = _dvm.CreateDataView(App.DataProvider.DataSet.Tables["Dates"]); 
                Binding binding = new Binding(); 
                binding.Source = _dataView; 
                GridMaster.SetBinding(ListView.ItemsSourceProperty, binding); 
                binding = new Binding(); 
                binding.Source = _dataView; 
                binding.Path = new PropertyPath("Dates_Tours"); 
                GridDetails.SetBinding(ListView.ItemsSourceProperty, binding); 
                binding = new Binding(); 
                binding.Source = _dataView; 
                binding.Path = new PropertyPath("Dates_Tours/Tours_Orders"); 
                GridSubDetails.SetBinding(ListView.ItemsSourceProperty, binding); 
                binding = new Binding(); 
                binding.Source = _dataView; 
                binding.Path = new PropertyPath("Dates_Tours/Tours_Orders/Orders_OrderLines"); 
                GridSubSubDetails.SetBinding(ListView.ItemsSourceProperty, binding); 

    Thank you in advance for any help and/or for time to reed my post.

    If it's not possible, how can I make ?

    Monday, February 16, 2009 3:56 PM