Drop down with Re:new using AB_NewlookDropdownController

  • 371 Views
  • Last Post 17 March 2016
DerekMaciak posted this 17 March 2016

The AB_NewlookDropdownController is a class used to simplify the process of loading a combobox on a Newlook screen using data from the Accelerator for .NET. This class can be used in any WPF detailer that inherits AB_NewlookDetails Detailer. In the following example the steps to implement a newlook dropdown will be followed using the EasyBuy Auto Parts System as an example.

Setting up the Newlook Screen

In order for the AB_Newlook dropdown to work properly it must be setup based on the following naming convention:

  • A combobox control with the following properties set. This is not added in the designer, but by setting your field in the 'Identify' editor to the type 'Combo Entry Field'
    • Name: Set to a name appropriate to the combo box. In this example the name is 'ParentName' Substitute this value anywhere you see in this document, as all other newlook controls are based off of this.
    • Sorted: False
    • Variable: var
  • A 'Search' CommandButton (Optional)
    • Name: Search
    • TakeFocusOnClick: True, this allows the event to be trapped in the .net portion of the solution
    • Picture: @\Images\Find.png, the find image will need to be in the \Images directory of your newlook solution. Image
    • PictureSize: PicSizeStretch
  • An 'Open' CommandButton (Optional)
    • Name: Open
    • TakeFocusOnClick: True, this allows the event to be trapped in the .net portion of the solution
    • Picture: @\Images\Vb_open2.png, the find image will need to be in the \Images directory of your newlook solution. Image
    • PictureSize: PicSizeStretch
  • An 'New' CommandButton (Optional)
    • Name: New
    • TakeFocusOnClick: True, this allows the event to be trapped in the .net portion of the solution
    • Picture: @\Images\Vb_new.png, the find image will need to be in the \Images directory of your newlook solution. Image
    • PictureSize: PicSizeStretch
  • A hidden Entry field for the 'key'. This is used to set the actual value based on the combobox value. This is only necessary if you have a key as well as a value and you do not wish to show the key.
    • Variable: varID

Setting up the .Net Detailer

  • Step 1: Create an instance of AB_NewlookDropdownController and set appropriate properties in the am_OnInitialized() Method
    • ap_SbInterfaceReferenceID: This must be setup in the SB Interface Modue, each module should ahve a generated dropdown entry
    • ap_NewlookControlName: Name of the combo entry field setup in the newlook screen
    • ap_DetailType: Type of Detail Opened when clicking the Open or New command buttons
    • ap_ViewModelType: View Model type used to select data to populate the combo box
    • ap_EntityType: Type of entity returned by the View Model Selection
    • ap_DisplayMemberFieldName: Name of the 'Value' field in the entity
    • ap_KeyFieldName: Name of the 'key' field in the entity
    • ap_CurrentView: View used to sort/filter combo box items
    • ap_ScreenName: Screen the combo box should be populated on
  • Step 2: Enroll AB_NewlookDropdownController in ap_NewlookDropdownControllers collection

DerekMaciak posted this 17 March 2016

Example

The following example uses the EasyBuy Autoparts demo system

  • Step 1: Open the EasyBuy newlook solution in SOA architect. Open the 'Customer Detail Update' screen. On the identify screen we have the two fields we need to set. Set the Parent Name field to category 'Combo Entry Field' and the ID field to 'Entry Field'
  • Step 2: Set the properties on the newlook design screen:
    • After the search button properties are set, it is easiest to simply copy and paste the command button, then change the name and picture properties. 
  • Step 3: In the EasyBuyAutoParts .NET 'CustomerOrders.sln application', 'open CustomerDetail.xaml.cs'
    • Add the following code block to am_SetParentProperties() at the end of the method
var parentHandler = new AB_NewlookDropdownController()
{
    // This must be setup in the SB Interface Modue, each module should ahve a generated dropdown entry
    ap_SbInterfaceReferenceID = "CustomerDropDown", 
    // Name of the combo entry field setup in the newlook screen
    ap_NewlookControlName = "ParentName",
    // Type of Detail Opened when clicking the Open or New command buttons
    ap_DetailType = typeof(WPF.Customer.CustomerDetail),
    // View Model type used to select data to populate the combo box
    ap_ViewModelType = typeof(CustomerVM),
    // Type of entity returned by the View Model Selection
    ap_EntityType = typeof(BOS.CustomerDataEntity.CustomerEntity),
    // Name of the 'Value' field in the entity
    ap_DisplayMemberFieldName = "Name",
    // Name of the 'key' field in the entity
    ap_KeyFieldName = "InternalID",
    // View used to sort/filter combo box items
    ap_CurrentView = "YD1CLF1",
    // Screen the combo box should be populated on
    ap_ScreenName = "CustomerDetailUpdate"

};
 // Enroll the Dropdown Controller for automatic population and command processing
ap_NewlookDropdownControllers.Add("ParentName", parentHandler);

The Parent Name should now populate with the names of all customers and the Search, Open, and New should open their respective commands.

You can also condition what dropdowns load based on the screen name by moving the creation of the AB_NewlookDropDownController to the am_NewlookscreenChanged method and conditioning based on screen name.  Make sure you create the AB_NewlookDropdownController prior to calling the base.am_onNewlookScreenChanged or the data will not load properly in the dropdown. Here is an example:

protected override void am_OnNewlookScreenChanged(object sender, EventArgs e, string ScreenName, string ScreenTitle)
{
    if (ScreenName == "CustomerDetail" || ScreenName == "CustomerDetailUpdate")
    {
        #region  //  Custom Code to handle Customer Drop Down on Newlook Detail
        var dropdowncontroller = new AB_NewlookDropdownController()
        {
            // This must be setup in the SB Interface Module, each module should have a generated dropdown entry
            ap_SbInterfaceReferenceID = "CustomerDropDown",
            // Name of the combo entry field setup in the newlook screen
            ap_NewlookControlName = "ParentName",
            // Type of Detail Opened when clicking the Open or New command buttons
            ap_DetailType = typeof(WPF.Customer.CustomerDetail),
            // View Model type used to select data to populate the combo box
            ap_ViewModelType = typeof(CustomerVM),
            // Type of entity returned by the View Model Selection
            ap_EntityType = typeof(CustomerEntity),
            // Name of the 'Value' field in the entity
            ap_DisplayMemberFieldName = "Name",
            // Name of the 'key' field in the entity
            ap_KeyFieldName = "CustomerInternalID",
            // View used to sort/filter combo box items
            ap_CurrentView = "YD1CLF1",

        };

        dropdowncontroller.ap_ScreenName = ScreenName;

        // Enroll the Dropdown Controller for automatic population and command processing
        if (!ap_NewlookDropdownControllers.ContainsKey(dropdowncontroller.ap_NewlookControlName))
        {
            ap_NewlookDropdownControllers.Add(dropdowncontroller.ap_NewlookControlName, dropdowncontroller);
        }

        #endregion
    }


    base.am_OnNewlookScreenChanged(sender, e, ScreenName, ScreenTitle);
}

Close