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 

Top Row In VirtualTree

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



Joined: 07 Apr 2016
Posts: 40

PostPosted: Mon Apr 11, 2016 1:31 pm    Post subject: Top Row In VirtualTree Reply with quote

I don't know what it's called, but a row is generated in the top of VirtualTree which appears to reference System.Data.Entiy.Internal.DbLocalView. I didn't even know this object existed in the namespace, but there it is. Neither the DataBaseBrowser nor DataSetBrowser samples display this top row. Can you tell me how to configure the VirtualTree so that it doesn't display, please?

Thank you.

Back to top
View user's profile Send private message
EntityDev



Joined: 07 Apr 2016
Posts: 40

PostPosted: Mon Apr 11, 2016 2:52 pm    Post subject: Reply with quote

Ruh roh...ShowRootRow. I found it, please disregard.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Apr 11, 2016 10:18 pm    Post subject: Reply with quote

Alternatively some people like to still show the Root Row but change the display text/icon to something else. You can do this by configuring a data binding for it.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
EntityDev



Joined: 07 Apr 2016
Posts: 40

PostPosted: Tue Apr 12, 2016 7:39 pm    Post subject: Reply with quote

Thanks, I figured some probably make use of that row.

How do I configure a binding for it?

This is related to a new question I was going to ask, so I'll include it here.

Say I have a foreign key on table Customer, to State.StateID (as in State or Province). It is represented in class Customer by a property named StateID.

Is it possible to have a column in the bound Customer row which does a lookup into table/object State, for the StateName (or Abbreviation, etc.)?

If there is a nice data binding method for that, then I imagine it'd make use of an overridden .ToString function on the State object...
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Apr 12, 2016 11:29 pm    Post subject: Reply with quote

Quote:
How do I configure a binding for it?


You can just add an object binding and set the TypeName to System.Data.Entity.Internal.DbLocalView. In the CellBinding you can then set the Format property to the text you want to display (instead of the item value using the {0} placeholder).

Quote:
Is it possible to have a column in the bound Customer row which does a lookup into table/object State, for the StateName (or Abbreviation, etc.)?


The DataSet bindings have a mechanism that supports this type of lookup via relations however Object bindings don't have anything like that built in. You can however implement it yourself. The simplest way is to add a StateName property to your Customer class that does the lookup and returns the name and bind to this instead of the ID. If it isn't possible to modify the Customer class then you can also achieve this by mixing some programmatic binding with you object bindings just to handles this.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
EntityDev



Joined: 07 Apr 2016
Posts: 40

PostPosted: Wed Apr 13, 2016 12:06 pm    Post subject: Reply with quote

Thank you for your reply.

Quote:
You can just add an object binding and set the TypeName to System.Data.Entity.Internal.DbLocalView. In the CellBinding you can then set the Format property to the text you want to display (instead of the item value using the {0} placeholder)


This control is new to me and I'm afraid I don't understand these steps. Although I've tried them both with existing bindings, and starting with an empty tree, I'll assume empty tree.

I added an object binding (Or row binding? The naming is confusing). I set the TypeName property to System.Data.Entity.Internal.DbLocalView. You then wrote, "In the CellBinding, you can..." But there is of course no CellBinding, yet. So I assumed I should create one, which I did. And of course there is not yet a column to bind it to. So I created one and bound it. In the CellBinding, I set the Format property to some string.

I then loaded up some entities, Jobs in this case, and set the datasource of the tree:

Note: context is of type System.Data.Entity.DbContext.

Code:
context.Jobs.Load()
Me.VirtualTree1.DataSource = context.Jobs.Local


Here is the result. I've likely misinterpreted your instructions. As you can see, the type I configured the binding with has been supplanted by System.Data.Entity.Internal.DbLocalView`1[DPMBranchModel.Job].



There are in fact four Jobs in the database. The DynamicProxies are displayed, which is a wrapper EntityFramework places around the object in order to track it with DbContext.

Thank you.
Back to top
View user's profile Send private message
EntityDev



Joined: 07 Apr 2016
Posts: 40

PostPosted: Wed Apr 13, 2016 1:05 pm    Post subject: Reply with quote

Quote:
The DataSet bindings have a mechanism that supports this type of lookup via relations however Object bindings don't have anything like that built in. You can however implement it yourself. The simplest way is to add a StateName property to your Customer class that does the lookup and returns the name and bind to this instead of the ID. If it isn't possible to modify the Customer class then you can also achieve this by mixing some programmatic binding with you object bindings just to handles this.


The classes are generated (quite often, during development), so adding a StateName property would be redundant and I'd consider it poor design. Besides, the StateName is available across the relationship in EF. Programmatic? Sure, but...I'd love for someone to do the ton of work required to duplicate the DataSet functionality in VirtualTree for EntityFramework DbContext. The relationships are defined in the Model. I'd pay three times what you get for a license now. Unfortunately, DbContext objects do not implement ITypedList, nor IBindingList, nor IBindingListView. Or even IDataErrorInfo. So, we often generate our own classes using a T4 template, typically implementing most of the above. ITypedList I'm still working on.

So you may consider this a feature request. Maybe Microsoft shouldn't have recommended EF for all new data-driven applications, but they have. Dang. DataSets are clunky, but at least they're thorough. I may yet switch to them for this project. Since I haven't even bought a license for the VirtualTree yet, I'll just point out a couple things which might have universal appeal:

1. The VirtualTree editor really needs a splitter between the TabControl and the PropertyGrid.
2. In both the PropertyGrid and in the AutoGenerate dialog, the ComboBoxes for Types a) do not display nearly enough rows, and b) should auto-adjust for width.

Actually, the width thing isn't all that bad - it can be accomodated for, in both controls. But most of the discovered types do have very long names. The height of the dropdown portion of both ComboBoxes, however, is not nearly enough. The thing discovers about a gazillion Types. Thanks once again. Despite my concerns, this still may the best grid/tree type control I've seen. Still evaluating...

And I should also mention - I will study the Programmatic Data Binding section of the .chm.
Back to top
View user's profile Send private message
EntityDev



Joined: 07 Apr 2016
Posts: 40

PostPosted: Wed Apr 13, 2016 1:33 pm    Post subject: Reply with quote

Judging by my reading of the Programmatic Data Binding section, it appears as though I can achieve all of the things I mentioned about Entity Framework, as long as I can implement ITypedList on my classes. I already implement IBindingList and a host of other interfaces.

I'll work on that, and give Programmatic a whirl. I believe I might derive from your control and tailor it for Entity Framework DbContext.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Apr 13, 2016 10:41 pm    Post subject: Reply with quote

Quote:
1. The VirtualTree editor really needs a splitter between the TabControl and the PropertyGrid.
2. In both the PropertyGrid and in the AutoGenerate dialog, the ComboBoxes for Types a) do not display nearly enough rows, and b) should auto-adjust for width.

We will take a look at these suggestions.

The earlier issue with binding to the root row is because you are binding to a generic type instantation (sorry I didn't realize that from your previous post). Everything else you described seemed correct. See the following thread about binding to generic types

http://www.infralution.com/phpBB2/viewtopic.php?t=557

If you don't want to add the StateName property to your class (which I understand) then the alternative is to manage this in the user interface layer by handling the GetCellData event and doing the conversion from StateID to StateName in this event. You can still use the design time Object Bindings to manage all of the other bindings. The DataSetBrowser sample project shows how do do this. It mixes programmatic binding with Data Set binding - but the principle is the same. If you want the user to be able to edit the State then you will also need to handle the SetCellData event to manage setting the StateID back into the data source.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
EntityDev



Joined: 07 Apr 2016
Posts: 40

PostPosted: Thu Apr 14, 2016 6:46 am    Post subject: Reply with quote

I've made some progress by following the thread you posted, but am still missing something. I can get the "collection" row to display with whatever I typed into the Format property. I assume I need to set a ChildProperty. The only two Fields available are Count and Item. I selected Item, but no child rows are displayed.

I'll test this later, with simple classes and a more 'traditional' collection type...one which is not found in the System.Data.Entity namespaces, and will post here afterwards.

Many thanks.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Apr 14, 2016 7:50 am    Post subject: Reply with quote

If your data source is a collection (as in this case) then you need to set the ChildProperty of your root row binding to this. This tells VirtualTree that the object you have bound is itself the collection of child objects.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
EntityDev



Joined: 07 Apr 2016
Posts: 40

PostPosted: Thu Apr 14, 2016 1:23 pm    Post subject: Reply with quote

Yes, I've been setting the ChildProperty. Actually I've discovered that either "this" or "Me" will work.

And this I discovered by leaving TypeName blank and setting in the constructor of the form:
Code:
Me.CollectionRowBinding.Type = GetType(Infralution.Common.SortableBindingList(Of Master))


I really want to be able to do this in the designer, however. I tried all manner of setting the TypeName in the VirtualTree editor. Support's code from the referenced thread:
Code:
MyNamespace.MyGenericType<MyNamespace>, MyAssembly


Actually, that's not right. When I paste the code block from the other thread and put code tags on it, it looks like the above. It has been reformatted by the forum code, I suppose. I removed the code tags and it still reformats it, and looks just like the above code block.

Anyway, here it is, in somewhat stilted form. I replaced the angle brackets with curly braces.

MyNamespace.MyGenericType{MyNamespace.MyType, MyAssembly}, MyAssembly

In VB.Net, that'd be:
Code:
MyNamespace.MyGenericType(Of MyNamespace.MyType, MyAssembly), MyAssembly


The namespaces involved here would make this:
Code:
Infralution.Common.SortableBindingList(Of DispatchMasterBranch.Master, DispatchMasterBranch), Infralution.Common

But when I paste that into the TypeName property in the editor, Virtual Tree throws an exception:

(Properties Window)
Property value is not valid.
The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

Can you please show me how to format the string so that it will be accepted in the editor? I also tried this in the TypedListName property, on a whim. That doesn't work. Is the use of that property tailored for DataSets?

Thank you.
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