New Posts New Posts RSS Feed: [DEFERRED] Limiting (or Filtering) ListConverters
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

[DEFERRED] Limiting (or Filtering) ListConverters

 Post Reply Post Reply
Author
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 Topic: [DEFERRED] Limiting (or Filtering) ListConverters
    Posted: 02-Oct-2007 at 6:32pm
If I display a list of contacts on the sales order window, my default implementation of a ListConverter returns all contacts regardless of the customer selected on the sales order.  How do I limit the contact list on the sales order to just the contacts associated with the customer?
 


Edited by Linguinut - 23-Oct-2007 at 5:20pm
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: 05-Oct-2007 at 8:27am
Here's the question a different way:
 
How can a bound entity on a view limit the items in a list filled by a custom listconverter?
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: 08-Oct-2007 at 3:52pm
 
A list converter binds the list to an EntityList<T>.
 
An EntityList can have a ListManager that applies a predicate to the list of entities for filtering.
 
Look at some of the list managers in Cabana for examples.
 
Bill J.
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: 08-Oct-2007 at 4:04pm
How do you send a predicate at runtime so that the list changes dynamically?  Where, specifically, are these examples?  ListConverterService?
 
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: 09-Oct-2007 at 10:38am
As Ward says, "walk the dog" through the code:
 
Unsurprisingly, the ListConverters for Cabana are supplied by the ListConverterService (in the Foundation module).  This inherits and uses methods from ListConverterServiceBase (in the IdeaBlade.Cab.UI project of the CabanaLib solution).  In particular, several of the Make... methods call

AddListManager_KeepExistingEntitiesOnly(converter)

on the newly created converter.  This method in turn gets the entity list from the converter and adds a ListManager.  The ListManager constructor accepts a Predicate<T> (a static delegate accepting a T and returning a boolean) that determines if an entity should be included in the list.
 
You should be able to adapt this logic for your list manager.
 
Bill J.
 
 
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: 09-Oct-2007 at 11:12am
Sometimes when I "walk the dog" I may be holding the leash but why the dog would go a certain way is beyond my understanding.
 
Are you saying that I will need to create my own custom ListManager; or, could I utilize the current ListManager somehow?  I would rather prefer the latter.  If the ListManager is able to keep lists current based on the predicate supplied, how can I provide the manager the information that it needs to do that? 
 
It just seems like the dog cannot walk into that neighborhood.
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: 09-Oct-2007 at 1:37pm
I am listening for a binding source change for the customer in an older DevForce app then firing the following:
 
private System.Windows.Forms.BindingSource mContactsBS;
private EntityList<ContactMaster> mContacts;
 
mContacts = new EntityList<ContactMaster>(mCurrCust.ContactMasters);
ContactMaster mNullContact = mPersMgr.GetNullEntity<ContactMaster>();
mContacts.Insert(0, mNullContact);
mContactsBS.DataSource = mContacts;
mContactMasterComboBox.DataSource = mContactsBS;
mContactMasterComboBox.DisplayMember = "FirstLast";
mContactMasterComboBox.ValueMember = "__Self";
 
This "refreshes" my contact list nicely.  Do I need to do the same within this CAB application?


Edited by Linguinut - 09-Oct-2007 at 1:38pm
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: 09-Oct-2007 at 5:40pm
Here is what I have done:
 
1)  Added an event handler on the view for my customer combo box (SelectedIndexChanged event):
 
private void OnChangeCustomer(object sender, System.EventArgs e)
{
    if (mPresenter != null)
    {
        mContactindexComboBox.DataSource = mPresenter.CustomerChanged();
        mContactindexComboBox.DisplayMember = "FirstLast";
        mContactindexComboBox.ValueMember = "Contactindex";
    }
}
 
2)  Added the code in the presenter to return a new BindingSource:
 
public BindingSource CustomerChanged()
{
    int mCustIndex = ((SalesOrderMaster)this.CurrentItem).CustomerMaster.CustIndex;
    EntityQuery aQuery = new EntityQuery(typeof(ContactMaster), ContactMaster.MasterindexEntityColumn, EntityQueryOp.EQ, mCustIndex);
    mContacts = MainPm.Manager.GetEntities<ContactMaster>(aQuery);
    mContactsBS.DataSource = mContacts;
    return mContactsBS;
}
 
Is this the right way to handle this?
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: 11-Oct-2007 at 9:54am
This may not be the right way to do this. 
 
The list is getting changed properly (note: I am using the EventBroker successfully).  But, and with DF/CAB there always seems to be a 'but', the list is not synchronized with the parent data.  Two issues:  1) the list is not showing the selected item; and B) changing the list does not change the parent record.
 
"O, what a tangled web we weave . . . " - Sir Walter Scott
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: 11-Oct-2007 at 10:34am
No matter what I do here, it still does not work:
 
--change binding to table
--change binding to foreign key
--change display member
--change value member to index
--change value member to __Self
 
For some reason, as soon as I set the combobox binding source to the newly filtered list, the connection with the parent entity breaks and is not restored.
 
I have been working on this for over a week.  Can anyone shed some light on this, please?
 
 
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: 13-Oct-2007 at 7:40am
I am really mystified on this issue.  Any ideas, tips, or tricks are extremely welcome.
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: 13-Oct-2007 at 11:27am
Here are some more problems...
 
I create a list called EquipmentList
 
I add the list to a control view that handles one of the details of a Work Order (equipment assigned).
 
When I add a new equipment assignment (click the add new button on my control view), the new equipment assignment comes up (empty and ready to be filled).  No problem there.  But when I go to click the combobox to select the available equipment, I get a nasty error about the object not found.  System.Windows.Forms is trying the getText method and is not able to.
 
What is up with that?  The combobox works beautifully before I click add new.  What happens to the combobox after I click add new???  Why should anything happen to it?  It is the same list regardless of a new or existing assignment.
 
I will do some more debugging, but a little guidance on how these ListConverters are supposed to work would be great.  Perhaps I am doing some fundamental thing wrong.  Perhaps I am using them in contexts they were never designed to be used.  Please help...anyone.
 
Thanks.
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: 16-Oct-2007 at 12:44pm
Not getting much help huh?
 
Well I would like to do the same thing.
 
I would like to filter the data that is going to be put into the combobox instead of having all the records I only want those with a certain criteria.
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: 16-Oct-2007 at 1:16pm

Nope.  This question has been out here for some time.  Perhaps I am not making myself clear enough.  I don't always know the right questions to ask or the right CAB terms to use.  I will hope for an answer but I am not expecting one.

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: 19-Oct-2007 at 10:03am
I will close this thread and open a new one with the question posed differently.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down