New Posts New Posts RSS Feed: [Resolved]ListConverter Issue
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

[Resolved]ListConverter Issue

 Post Reply Post Reply
Author
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Topic: [Resolved]ListConverter Issue
    Posted: 10-Oct-2007 at 10:01am
I have tried on multiple occassions to use the ListConverter service. I have been successful in getting the items I desire. My problem is that my existing item is never selected.
 
I am not sure if the list is being set after the value is assigned to the combobox.
 
I am setting the list converts in the OnViewContextSet, to verify that my binding manager is not null.


Edited by orcities - 11-Oct-2007 at 9:17am
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 10-Oct-2007 at 11:08am
When I bind the list control on the view I use the foreign key field (it will default to textbox, so I change it to combobox).  I place the binding commands (SetBindingListConverter) in the presenter following the base.OnViewSet command.
Back to Top
Bill Jensen View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Jul-2007
Location: United States
Posts: 229
Post Options Post Options   Quote Bill Jensen Quote  Post ReplyReply Direct Link To This Post Posted: 10-Oct-2007 at 1:04pm

Looks like you're calling SetBindingListConverter() in the right place.

Have you tried binding your combo to the relation property rather than the foreign key field?  This retrieves the set of foreign objects, rather than foreign key values.  Then set the DisplayMember to the property (e.g., Name) of the foreign object to appear in the list.
 
Bill J.
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 10-Oct-2007 at 1:13pm
I believe that is what I am doing.
 
My example: Address table has foreign key to Types (called AddressType)table
 
I have used hte ControlBindingManager to add AddressType, not the key property. It gives me the combobox.
 
Then in the presenter I use the following to bind the data:
 
EntityPropertyDescriptors.ContactAddressPropertyDescriptor descriptors = EntityPropertyDescriptors.ContactAddress;
SetBindingListConverter(descriptors.AddressType, ListConverterNames.AddressType);
 
It binds the list converter but it doesn't give me my current value. It also has an empty space at the top of the combobox that seems to be a null entity that if selected crashes the application.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 10-Oct-2007 at 1:19pm
Read through http://www.ideablade.com/forum/forum_posts.asp?TID=460 . . . that may shed a little more light on the subject.  Follow the example in Cabana that has a MakeEntityList and MakeEntityIDList.  Call both from the presenter:
 
SetBindingListConverter(descriptors.AddressType, ListConverterNames.AddressType);
SetBindingListConverter(descriptors.AddressIndex, ListConverterNames.AddressTypeID);
 
Make sure you are binding the combobox to the AddressIndex field, not the related entity list.
 
Also, I added the AutoValidate.EnableAllowFocusChanged (see Cabana) which alleviated some of the navigation issues in the view with empty lists and such.  I may need to adjust that a little later on.
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 10-Oct-2007 at 2:01pm
By changing it and binding to the ID and adding that ListConverter it worked. I would of thought that it would work with the entity itself.
 
Tx.
 
One more issue. I am getting and extra blank option in my combobox that is null and if selected causes some issues.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 10-Oct-2007 at 2:05pm

the form.autovalidate may be the problem...it was for me.  try adding the following to your view code:

//right after the SetPresenter call
AutoValidate = pPresenter.SetAutoValidation();
 
In the presenter place the following:
 
/// <summary>Set how the View constrains focus change when validation fails.</summary>
/// <remarks>Can also disable auto validation altogether.</remarks>
public AutoValidate SetAutoValidation()
{
    // Play with the choices.
    //return AutoValidate.EnablePreventFocusChange; // Locked in control
    return AutoValidate.EnableAllowFocusChange; // Can move
    //return AutoValidate.Inherit; // Do what the parent container does
    //return AutoValidate.Disable; // Don't autovalidate.
}
 
I tried all of them and this one worked best for me.  For now... I may run into other validation issues later, but I will deal with them as they come up.


Edited by Linguinut - 10-Oct-2007 at 2:06pm
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 10-Oct-2007 at 3:07pm
That didn't work. If I am adding an new item that first element in the list is blank. And when I try and change it is when it crashes the app due to Object Ref. not set to an instan... you get the point. The first entity in the list is null when it shouldn't even be there.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 10-Oct-2007 at 6:18pm

Is it just a straight entity list filling the combobox?

I'll check and see how my lists are getting filled...maybe they have a null entity at the top, too.
Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 11-Oct-2007 at 7:08am

Yup. It is a straight entity list. If I remember correctly there is a way to make a null entity equal to a base object or base values. But I can't remember how. And I am not sure why it is event putting it there.

Back to Top
orcities View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Aug-2007
Location: United States
Posts: 454
Post Options Post Options   Quote orcities Quote  Post ReplyReply Direct Link To This Post Posted: 11-Oct-2007 at 9:16am
I ended up overriding the UpdateNullEntity for the Entity and setting the value that was the set as the DisplayMember and it works fine.
 
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down