svyLookup

Overview

The svyLookup module provides a UX pattern for quickly finding and returning records within PopUp or Dialogs. It is similar to a type-ahead field, filtering the list of available selection as the user types, but allows for an extended UI, multi-selection searching and data-binding. Differently from the type-ahead field allows to show listed items within a sortable grid with multiple columns.

This module provides out-of-the-box grid implementation templates, but is also extensible to allow for other UI types and templates.

This quick screencast shows the example

Example

Example Look-Up

Key Features

  • Multi-Select or Single-Select

  • Use Related Data

  • Format Values

  • Style Values

  • Valuelist to show display values in grid

  • Custom Templates

  • PopUp or Dialogs

Quick Start

It takes just a few lines of code to configure and show a robust lookup component. The selected record can be handled in a callback.

Show Lookup

The svyLookup module provide easy to use API to create and program Lookup objects bound to any dataSource. LookupFields are added defining the data to be visualized in the lookup grid and the searchable data. When the lookup is shown as a non-modal dialog, the selected records are returned in a callback function;

Handle selection in callback

The selected records are returned in the selection callback; if the lookup DataProvider has been set the selected values will also be returned in the callback.

Multi Select Lookup

For multi-selection simply set the MultiSelect flag to true

Example Look-Up Multi-Select

Lookup Types

The Lookup can be shown as a PopUp, Modal and Non-Modal Window; PopUp and Window can be customized to best suit your experience.

Show as Default Popup

Show as Custom PopUp

Show as Default Modal Dialog

Show as Custom Dialog

Lookup DataProvider

The Lookup DataProvider can be optional set to get direct access to the desired selected values for a quicker access to the desired selection. If the Lookup is shown as a modal window, which directly returns the selection instead of triggering a callback, the selected values will be returned instead of the selected records.

Example of Lookup DataProvider using non-modal window.

Lookup Parameters

Optionally custom parameters can be added to the lookup object; custom parameters can be retrieved in the selection callback from the lookup argument. Note that custom parameters do not have any effect to the lookup itself, are simply used to pass additional information to the selection callback.

Filter Lookup List

You would like to be able to filter the data shown in the lookup list; you can filter the data by creating the lookup object with a filtered Foundset.

Create Lookup from Valuelist

Is possible to show in a lookup the same items of a Servoy Valuelist; to do so you can create a lookup from a valuelist; the lookup will show the displayValues and return the selected realValues into the values argument of the select callback.

NOTE: Valuelist based on a database relation are allowed only if the relation is a global relation (relation items are either literal or scope/global variables). Custom valuelists can show up to 500 items in lookup.

Create Lookup from Custom Query

Is also possible to create a lookup directly from a custom query.

Restore Selection

In case of multi select lookup is a common requirement to keep the last selected items in lookup, so the second time the user will access to the lookup he can still keep his latest selection. If you re-use the same lookup object will remember the last selection; if you instantiate a new lookup object instead will have a clear state with no selection.

Is possible to restore the last selection programmatically by using the lookup APIs setSelectedRecords(records), setSelectedPks(pks) or setSelectedValues(values); the latter can be used only if a Lookup DataProvider has been set.

Restoring the last selection is particularly useful to restore user's selection after a new login session.

NOTE: restoring the selection is applicable only for multi select lookup.

Lookup Templates

The module provides out-of-the-box grid implementation templates, but is also extensible to allow for other UI types and templates. Every template offers a custom implementation as a Servoy Form extending the abstract form AbstractLookup It provides 4 out-of-the-box templates

  • svyLookupTable : Default template with single selection table. The Table in lookup form is based on the Servoy Extra Table component.

  • svyLookupNGTable : Variant of the single selection table build with the NG Grid

  • svyLookupTableMulti : Default template with multi selection table. The Table in lookup form is based on the Servoy Extra Table component

  • svyLookupNGTableMulti : Variant of the multi selection table build with the NG Grid

The template to be used in lookup can be set with the method setLookupForm.

You can also use your custom lookup templates using the setLookupForm method; check the wiki page Custom Templates to learn how to create a custom template.

Last updated

Was this helpful?