Suggest control type

The "Suggest K2BTools" control type extends the functionality of standard suggest controls provided by GeneXus (used when Control Type = Edit and Suggest <> No).

This is similar to the Dynamic Combo Box control type, that extends the functionality of standard GeneXus Combo Boxes.

The features present in this control type that were not present in its bare GX equivalent are:

  1. Better UI when showing the items (including images and other attributes).
  2. An option to add new items if they are not present in the list.

SuggestRuntimeAppearance
Suggest in runtime

Both these features are specified and work as in the Dynamic Combo Box control type.

Using the dataprovider datasource with this control type

When using the suggest control is used with the Attributes datasource, the database query is optimize to minimize the amount of records fetched from the DBMS and sent to the browser.

When the Dataprovider datasource is used with this control type that optimization must be implemented inside the dataprovider by the developer.

If a non-optimized dataprovider is used, the control will work as always, but its performance will not be optimal as filtering will be performed in the application server instead of the DBMS.

K2BTools will treat a Dataprovider as optimized for the suggest control when it meets this criteria:

  1. Its return type is the K2BT_ExtendedControlValues SDT.
  2. It contains the following IN parameters:
    1. &Prefix: Based on a character type, it will be used by K2BTools to pass the value typed by the user in the control.
    2. &SelectedValues: Based on the same type as the variable. Will be used to pass the values currently selected in the control (must be defined as a collection regardless of the variable definition).
    3. &Count: Based on a numeric type, it will be used by K2BTools to pass the value of the "Suggest Max Items" property.

The dataprovider must return the values matching the Prefix (up to the number passed in the &Count parameter) and the values corresponding to the &SelectedValues parameter (the &Count parameter should not be considered in this part).

A sample code for such a dataprovider is included below.

K2BT_ExtendedControlValues
{
    Item
    [Count=&Count]
    Where CityName.ToLower() like &Prefix.ToLower() + !"%"
    {
        value = CityId.ToString().trim()
        description = CityName
        imageUrl = CountryFlag.ImageURI
        detail = CountryName
    }

    Item
    Where CityId in &SelectedValues
    {
        value = CityId.ToString().trim()
        description = CityName
        imageUrl = CountryFlag.ImageURI
        detail = CountryName
    }
}

Collection variables

This control can be used in collection variables. When used in that context, the selected values will be shown as tags above the suggest input.

SuggestCollection
Suggest displaying a collection