View previous topic :: View next topic |
Author |
Message |
jaherbert
Joined: 27 Jan 2008 Posts: 43
|
Posted: Sun May 04, 2008 7:49 am Post subject: FindRow(item) == null in Recursive Tree |
|
|
I'm using DataSet binding and VT 3.8.0.
I added a ParentRelation (I had a ChildRelation) and FindRow(item) returns null, even if the the Row is actually visible. I'm not getting any debug message. "Working with Rows" references SuppressErrorMessages which appears to be outdated. Within the application, I'm rerouting Console messages to a window, but I don't see the message there, and I do see other messages in the Debug Output window. I see a reference to DisplayErrorMessage but haven't been able to use it.
Any ideas?
Thanks.
Last edited by jaherbert on Mon May 05, 2008 9:50 pm; edited 1 time in total |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon May 05, 2008 12:19 am Post subject: |
|
|
Quote: | "Working with Rows" references SuppressErrorMessages which appears to be outdated. |
You are right that documentation is a little out of date - we will fix it in the next release. The SuppressErrorMessages property is now called SuppressBindingExceptions - but it isn't used in this case - parenting errors are always displayed in the trace output window. To check this is working call FindRow("foo"). You should get the following in your OutputWindow:
Quote: | VirtualTree: Unable to find a row in the tree corresponding to the given item. There may be an error in the parent-child relations you have set up.
Error: Unable to find path
Path: foo
Ensure that you have:
A. Set the Parent properties appropriately in the Tree RowBindings; or
B. Handled the GetItemParent event and set the Parent property; or
C. Overridden the GetParentForItem and returned the correct parent object. |
What argument you passing to FindRow(item)? If you are binding to a DataSet table then it should be a DataRow from the table. If you have multiple levels within your tree then you need to ensure that the ParentRelation is set for each level. _________________ Infralution Support |
|
Back to top |
|
|
jaherbert
Joined: 27 Jan 2008 Posts: 43
|
Posted: Mon May 05, 2008 9:49 pm Post subject: FindRow (== null) in Recursive Tree |
|
|
You're right. I do get the message. I was looking in the Output window. It's in the Immediate window.
I figured out what I was doing wrong.
I have a single recursive relationship. I had only assigned the recursive relationship to binding.ChildRelation. Then I defined the inverse relationship (swapping the relationship's 2 columns) and assigned it to the ParentRelation. What I needed to do was assign the identical relationship to the ParentRelation. You're just reading it in reverse. So FindRow was confused about the parents (e.g., seeing multiple parents for a given row, when they were multiple children).
I wonder if you could have given a more descriptive error message in the Immediate window (e.g., if you were finding multiple parents). Alternatively, I noticed in the message you provide, there's a "Path" field which lists the types of rows it hits. I wonder if you could add some information here, like the values in the primary key for each row. It would have helped me realize my mistake sooner.
Thanks for the help. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon May 05, 2008 10:13 pm Post subject: |
|
|
Quote: | I wonder if you could have given a more descriptive error message in the Immediate window (e.g., if you were finding multiple parents). Alternatively, I noticed in the message you provide, there's a "Path" field which lists the types of rows it hits. I wonder if you could add some information here, like the values in the primary key for each row. It would have helped me realize my mistake sooner. |
The problem is that the FindRow algorithm (and error handling) is implemented at the core level which supports programmatic binding, object binding and DataSet binding. It doesn't have access to the primary field information that the DataRowRowBinding does. The path is created using the item.ToString(). Unfortunately for DataRows this just prints the type by default. You could override the DataRow.ToString() so that you get more helpful output. _________________ Infralution Support |
|
Back to top |
|
|
jaherbert
Joined: 27 Jan 2008 Posts: 43
|
Posted: Mon May 05, 2008 11:23 pm Post subject: |
|
|
Got it. Thanks. |
|
Back to top |
|
|
jaherbert
Joined: 27 Jan 2008 Posts: 43
|
Posted: Mon Oct 19, 2009 10:20 pm Post subject: |
|
|
Same tree. Another FindRow problem. Again returning null. There seems to be a RootRow confusion.
The DataTable has a path: A>B>C>D>E. Where A-E represent the IDs of the associated DataRows.
When I display this whole tree in VT, FindRow(E's DataRow) succeeds.
Now, if I filter the DataTable so that VT shows C>D>E, FindRow(E's DataRow) returns null.
And the debug message lists the whole path A>B>C>D>E.
What am I missing? |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Oct 19, 2009 11:51 pm Post subject: |
|
|
This is because the default implementation of DataRowRowBinding.GetParentForItem which constructs the tree path for a given item doesn't know that you have set the DataView RowFilter to start the tree with a different root to the "true" root. The way around this is to handle the DataRowRowBinding.GetParent event and check for this condition yourself eg
Code: | private void rowBindingItem_GetParent(object sender, GetParentEventArgs e)
{
ItemDataSet._ItemRow thisItem = e.Item as ItemDataSet._ItemRow;
e.Parent = thisItem.ItemRowParent;
if (e.Parent == _rootItem)
e.Parent = null;
} |
Where _rootItem is the _ItemRow being displayed as the root row by setting the DataView filter. _________________ Infralution Support |
|
Back to top |
|
|
jaherbert
Joined: 27 Jan 2008 Posts: 43
|
Posted: Tue Oct 20, 2009 4:43 am Post subject: |
|
|
That's great. Thanks. |
|
Back to top |
|
|
|