Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

IDataErrorInfo - Not seeing error indications in the tree

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
erikest



Joined: 30 May 2007
Posts: 17

PostPosted: Mon Jul 30, 2007 6:49 pm    Post subject: IDataErrorInfo - Not seeing error indications in the tree Reply with quote

Hello,

I'm trying to use the VT's built in support for the IDataErrorInfo interface, but I've been unsuccessful in actually having an icon or tooltip appear. I've stepped through with the debugger and watched as the tree accessed the interface (which worked appropriately), yet no indications are displayed in the tree. I'm using object bindings in this project exclusively, but according to help file as long as I'm using Row Bindings (which they are since I created them through the editor within visual studio) and implement the IDataErrorInfo interface, everything else is automatic. What am I missing here?

Thanks,
-Erik
_________________
Erik Taylor
Developer
EnergySoft, LLC.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Jul 30, 2007 10:36 pm    Post subject: Reply with quote

Hi Erik - is there any chance you could email us (support@infralution.com) a sample zipped project that illustrates what you are doing? That would help a lot in tracking down what the issue might be.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
erikest



Joined: 30 May 2007
Posts: 17

PostPosted: Tue Jul 31, 2007 6:58 pm    Post subject: Reply with quote

I've attempted to send a sample project (as a zip) but it bounced with an "Illegal Attachment" error...

My sample is incredibly simple:

created InfoTestObj with a string and bool property which have condtions for errors
InfoTestObj implements IDataErrorInfo and returns the expected values if there is or isn't an error
InfoTestObj has parent and children properties which point to an instance and list of InfoTestObjs respectively

created a vitrual tree control and docked it to a form
used auto generate to create an objectrowbinding for InfoTestObj, which was frustrating because I had to manually type in the InfoTestObj's full name, the one in the drop down didn't work and would complain about needing an assembly reference or a recompile (both bogus in this case since the project was compiled and the type was within the same project).
Assigned the parent and child properties for the rowbinding accordingly.

In the constructor of the form, I created an InfoTestObj for the datasource and then created ten more with parent/child relationships to the root.

When I ran it, two things didn't happen.

1) no expand icons or indications
2) no error icons or indications

-Erik
_________________
Erik Taylor
Developer
EnergySoft, LLC.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Jul 31, 2007 11:07 pm    Post subject: Reply with quote

It would really help to have the sample project. Often it is a minor detail which may not seem significant that causes issues like this. If we simply try to replicate problems from a description we may do something slightly differently (often because we have a different understanding about how things should work). I've just verified that our email provider is not blocking zip attachments - it may be your end. The easiest way around this sort of thing is usually to rename the file to have an innocuous extension eg myfile_zip.txt

What version of Virtual Tree are you using?
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
erikest



Joined: 30 May 2007
Posts: 17

PostPosted: Tue Jul 31, 2007 11:13 pm    Post subject: Reply with quote

I'll resend it with a new name. I'm using version 3.5.0.0
_________________
Erik Taylor
Developer
EnergySoft, LLC.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Jul 31, 2007 11:52 pm    Post subject: Reply with quote

Thanks for the sample - that made it fairly easy to locate the issues.

The expansion indicators are not displaying because you set the VirtualTree.DataSource before creating the children of the root node. Because the collection you have used for InfoTestObj.Children does not support the IBindingList interface VirtualTree does not update automatically - you would have to call VirtualTree.UpdateRows after adding the children.

The row error is displayed in the RowHeader. Because you have ShowRowHeaders set to false you don't see it.

There is in fact an issue with displaying the error indicator in a particular cell when using object binding with the IDataErrorInfo interface. Currently object bindings do not do this for you automatically. You can however implement this yourself by handling the GetCellData event and setting the CellData.Error explicity as follows:

Code:
private void testTree_GetCellData(object sender, GetCellDataEventArgs e)
{
        ObjectCellBinding cellBinding = rowBindingInfoTestObj.CellBinding(e.Column);
        cellBinding.GetCellData(e.Row, e.CellData);
        IDataErrorInfo errorInfo = e.Row.Item as IDataErrorInfo;
        e.CellData.Error = errorInfo[cellBinding.Field];
}


We will look at changing ObjectCellBindings in the next release to do this automatically.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
erikest



Joined: 30 May 2007
Posts: 17

PostPosted: Wed Aug 01, 2007 12:29 am    Post subject: Reply with quote

Sweet, that explains everything.... except why the auto generate couldn't auto generate from a selection from it's own drop down box. But I could really care less about that in the end.

In the work around you posted, cellBinding gets it's reference from rowBindingInfoTestObj. This seems to be an easy fix in the case where I only have one row binding, but what if I have twenty ObjectRowBindings? The GetCellDataEventArgs doesn't seem to come with any indicator for this, so how can I go about assigning error information in this context.

Thanks,
_________________
Erik Taylor
Developer
EnergySoft, LLC.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Aug 01, 2007 12:39 am    Post subject: Reply with quote

Here's a more general GetCellData event handler that uses the VirtualTree.GetBindingForRow to get the appropriate row binding:

Code:
       private void testTree_GetCellData(object sender, GetCellDataEventArgs e)
        {
            ObjectRowBinding rowBinding = testTree.GetBindingForRow(e.Row) as ObjectRowBinding;
            if (rowBinding != null)
            {
                ObjectCellBinding cellBinding = rowBinding.CellBinding(e.Column);

                cellBinding.GetCellData(e.Row, e.CellData);
                IDataErrorInfo errorInfo = e.Row.Item as IDataErrorInfo;
                if (errorInfo != null)
                {
                    e.CellData.Error = errorInfo[cellBinding.Field];
                }
            }
        }


Quote:
Sweet, that explains everything...except why the auto generate couldn't auto generate from a selection from it's own drop down box.


This is due to the peculiar way System.Type.GetType resolves type names to types. In some cases (for external assemblies) it requires a full (assembly qualified) type name - in others it won't resolve if you give it an assembly qualified type name. We will try to get a fix for this in the next release.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
erikest



Joined: 30 May 2007
Posts: 17

PostPosted: Wed Aug 01, 2007 12:42 am    Post subject: Reply with quote

Rock on.
_________________
Erik Taylor
Developer
EnergySoft, LLC.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Aug 02, 2007 4:48 am    Post subject: Reply with quote

Version 3.5.2 of Virtual Tree has now been released and fixes the issue with IDataErrorInfo and Object bindings. This release also fixes the issue with Auto Generate when the type is defined in the current project assembly.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
erikest



Joined: 30 May 2007
Posts: 17

PostPosted: Thu Aug 02, 2007 3:59 pm    Post subject: Reply with quote

So, if I want to display error information for a property of the bound object which doesn't have a column associated with it, I'll have to handle GetCellData and do it programmatically or associate the error with a property that is bound to a column?
_________________
Erik Taylor
Developer
EnergySoft, LLC.
Back to top
View user's profile Send private message
erikest



Joined: 30 May 2007
Posts: 17

PostPosted: Thu Aug 02, 2007 4:27 pm    Post subject: Reply with quote

I tried to have error messages display both for the property bound to the lone column in my tree (the display property) and for the actual property with the error. No icons or tooltips appear, despite the interface having been accessed numerous times to retrieve the error message. I tried turning row headers on to see if the row errors were at least popping up, but alas nothing.

Of course, in the incredibly simplified sample project I sent you, the error info works fine. The main difference between the two (besides the obvious level of complexity), is that the sample project uses editors to adjust the values, while the real project uses custom editors outside of the virtual tree.
_________________
Erik Taylor
Developer
EnergySoft, LLC.
Back to top
View user's profile Send private message
erikest



Joined: 30 May 2007
Posts: 17

PostPosted: Thu Aug 02, 2007 5:23 pm    Post subject: Reply with quote

I love solving my own problems Smile.

Okay, here's the dilly:

Using an external editor I changed the property value.
Virtual Tree smartly accessed the error info property, leading me to believe it would also update it's row display too, not so.
A call to UpdateRowData (or collapse and expanding parent) causes the display to refresh and the icon to appear.

Okay, so I'll admit, I haven't implemented all the nice binding interfaces yet. There's no INotifyPropertyChanged on the objects and the children object containers don't have IBindingList either yet. I'm guessing if I had these, then the tree would have automagically picked up the change in the property and refreshed its rows accordingly. What I don't understand is why the tree is smart enough to access the error info properties when I a) make the row visible, b) again when I select the row, c) immediately after a property value has changed (it got notified somehow) and d) when I leave the row, but doesn't take the next step and refresh the row display when it realizes there's an error...

Is this by design? I know I should implement the binding interfaces for the best, most reliable functionality, but there stills seems to be a little inconsistency with how the tree handles objects that don't have those interfaces.
_________________
Erik Taylor
Developer
EnergySoft, LLC.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Aug 02, 2007 11:02 pm    Post subject: Reply with quote

Quote:
There's no INotifyPropertyChanged on the objects and the children object containers don't have IBindingList either yet. I'm guessing if I had these, then the tree would have automagically picked up the change in the property and refreshed its rows accordingly


Correct. If the tree is not notified via the binding interfaces then you have to call UpdateRowData if you change the data (or UpdateRows if you make changes that affect the tree hierarchy). I'm not sure why you are seeing calls to GetCellData (that in turn calls your IDataErrorInfo interface) when selecting the row. I think there must be something else going on. Virtual Tree will only make calls to GetCellData if UpdateRowData is called (either directly or via binding notification) or additional rows are scrolled into view. I've just verified this is the actual behaviour.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
erikest



Joined: 30 May 2007
Posts: 17

PostPosted: Thu Aug 02, 2007 11:39 pm    Post subject: Reply with quote

Well, it's a complicated tree and I didn't implement everything in it, so maybe there are some calls to updaterows I'm not aware of. Thanks for verifying the behavior...
_________________
Erik Taylor
Developer
EnergySoft, LLC.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group