Here's the 411:
1) Enter the ListConverter name pairs for each list involved (e.g. Shipper and ShipperID) in the ListConverterNames.cs file in the Interface.Constants project/folder.
2) Add the pair to the CreateServiceItemCore method of the ListConverterService (Foundation Module)
Market example:
case (ListConverterNames.MarketList):
return MakeMarketListConverter();
case (ListConverterNames.MarketIDList):
return MakeMarketIDListConverter();
3) Create the MakeListConverter methods...one for each of the pair
Market example:
/// <summary> Make the global ListConverter for all Markets; </summary>
private ListConverter MakeMarketListConverter()
{
EntityListConverter<MarketMaster> converter = new EntityListConverter<MarketMaster>(EntityManager, EntityPropertyDescriptors.MarketMaster.MarketMstrDesc.Name, Editability.Optional);
AddListManager_KeepExistingEntitiesOnly(converter);
return converter;
}
/// <summary>
/// Make the global ListConverter for all Markets which can be Customers;
/// use with a MarketMstrIdx property.
/// </summary>
private ListConverter MakeMarketIDListConverter()
{
ListConverter converter = CopyConverter<MarketMaster>ListConverterNames.MarketList);
// Matches and updates the *Id* (index) rather than the Market object
converter.ValueMember = EntityPropertyDescriptors.MarketMaster.MarketMstrIdx.Name;
return converter;
}
4) Bind the lists in the view's presenter
Market example:
EntityPropertyDescriptors.CustomerMasterPropertyDescriptor descriptors = EntityPropertyDescriptors.CustomerMaster;
SetBindingListConverter(descriptors.MarketMaster, ListConverterNames.MarketList);
SetBindingListConverter(descriptors.Market, ListConverterNames.MarketIDList);
Note: make sure that these bindings fire before the base.OnViewSet().
5) When binding the loose controls, add the index/ID field (not the entity)...make sure to change the control to a comboxbox. Leave all defaults in the ListConverter
Build and run. That seems to work for me. It is a bit different than standard DevForce binding.
Again, for more examples, please see the Shared Editor module of the Cabana app.
Edited by Linguinut - 18-Sep-2007 at 4:58pm