• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 956
  • Last Modified:

Filter child rows from DataView

I have a dataset with two tables (Parent) and (child)

I have added a relation between thest two tables
dsPO.Relations.Add("Parent2Child",
dsPO.Tables("Parent").Columns("ID"),
dsPO.Tables("Child").Columns("ID"))

I filtered Inventory table for price>0
dsPO.Tables("Parent").DefaultView.RowFilter = "Price>0"

and assign to a datagrid
grdDetails.DataSource = dsPO.Tables("Parent").DefaultView

My question is is there any way filtering child rows. I want to filter for
Strike > 10 in Child table. When I put .
dspo.Tables("Child").DefaultView.RowFilter ="Strike > 10'"
Datagrid doesn't change or filter child rows.
0
97WideGlide
Asked:
97WideGlide
  • 3
  • 2
2 Solutions
 
Anurag ThakurTechnical ManagerCommented:
do you have 2 data grids or only one data grid
if there are 2 data grids one showing the parent and the other children then in that case when a parent is selected (index changed) you need to do a child row filter for that parent and then rebind the second grid
0
 
97WideGlideAuthor Commented:
I have only one data grid which displays the vew in hierarchical fashion.  
When you say "do a child row filter" do you mean to iterate through all the parent rows requesting the related childview of each parent row and filtering ?  I was trying to do it that way but my tables are pretty large (Parent 5K and Child 300K) and this was taking a prohibitively long time.  

Also, I need to filter the entire child table at once because I also need to present a cumulative total of all unfiltered children.  
0
 
Anurag ThakurTechnical ManagerCommented:
i dont think (my view point) what you are trying to achieve is a good approach

in such a circumstances i would have had a gridview in which i will show all the parents and when i select a parent i will reload the children in a details view
the only drawback that i see is that there is going to be a postback on every parent selected
if such is done then large data problem is solved.
0
 
97WideGlideAuthor Commented:
Keep in mind that I will be processing this data so it is not just a question of how best to display it.

So, with that in mind, using your solution, how will I get things like a count of all of the rows which made it through the child filter?

For example, consider a parent table of 5K junkyards and a child table of 300K salvage parts in those junkyards.  I want to be able to filter the junkyards to get say, all located West of the Missippi.  Then I want to further filter the child table to limit the parts to all those valued more than say, $1000 or those which cost less than $30 to ship, or both.  At any given time I want to have a count of the total number of junkyards and parts that remain unfiltered.  
0
 
97WideGlideAuthor Commented:
Found a solution.  
A DataViewManager solves this problem very well.  Just remember to rebind the DVM after filtering or sorting so that the updates are available to your grid.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now