Webanizr Logo
Open / sluit menu
Module dynamicList

Last change: September 18, 2019

Current version: 1.6.1

The dynamicList module loads data from the lsitdata service from Webanizr. Configuration for this request is either given in the params parameter or in data atttributes in the targeted dom element. 

syntax

webanizr.collect('callApi', parameters, callback)
webanizr.send('callApi', data, parameters, callback)

data (send only)

The data that is used for filtering or searching in the list items.

parameters

The dynamicList module accepts the following parameters:

id__dom (required)

The dom element in which the list should be loaded.

maximumitems__list (optional)

The maximum number of items in the list. Overwrites any value in the data-dlmaxitems attribute.

filter__data (optional)

A filter definition to apply to the list. Overwrites any value in the data-dlfilter attrinute.

query__searchindex (optional)

The query to search in the index given by the data-dlsearchindex. The results will be used to filter the list based on this query.

search__preset (optional)

The type of search you want to perform. Options are:

  • cross_fields: search in all fields, words from the search may appear in seperate fields

  • full_doc_match: search in all fields, words must all be in the same field

  • full_doc_fuzzy: same as full_doc_match but with fuzzy search applied

boost__results (optional)

Boost the score of items when the given field matches the search. You can provide multiple fields, all with their own boost value: { one__field : 2, two__field : 5 }. Any value above 1 will increase the score. 

filtered__form (optional for send)

Tells the module to use the data from data as input for the search. The value of this parameter is a JSON object containing the parameters explained next.

The value from filtered__form.query__field will be used for the main text search. All other fields, if set, not empty and not equal to "0", will added as mandatory term queries to the search.

filtered__form.search__preset (optional for send)

Applies the search preset when using data from a filtered form. Same values apply as in the search__preset parameter.

filtered__form.query__field (optional for send)

The key in the data that contains the text search query.

filtered__form.boost__results (optional for send)

Applies boost to fields when using form data for the search. Same values as the requalar boost apply.

Data attributes

The dynamicList module checks for the following data attributes is the targeted dom element:

data-dllistname (required)

The name of the table in which the reuested data can be found.

data-dltemplateid (required)

The id of the template to use for displaying the results.

data-dlmapping (required by the service)

The mapping of mustache names in the template and the datanames to generate there value. The mapping should be stored as a JSON array in this data attribute.

data-dlkey (required by the service)

The policy key to gain access to the data.

data-dlmaxitems (optional)

The maximum number of items to be loaded. If this attribute is not set, the service loads a maximum of 30 elements. Can be overwritten by maximumitems__list in the parameters.

data-dlfilter (optional)

The filter to apply to the list. It is a JSON list in the following forma [ fieldname, comparission operator, value ], i.e. [ "iAge", ">", 21 ]. Can be overwritten by fitler__data in the parameters.

data-dlsearchindex (optional)

An id of a search index. The search index will be used when searching with the query__searchindex parameter.

data-dlsorttype (optional)

The type of sorting that has to happen. The following options can be used:

  • searchscore: use the scoring from the search as sorting. The item with the highest score comes first
  • database-natural: use the sorting set for this table in the backend as sorting mechanism

callback

The callback function is called after the data is retreived and shown using the given template. The retreived data is passed on to the callback function.

Changelog

  • September 18, 2019: 1.6.1 - Updated requirement on sendToAPI to 1.2.0
  • August 26, 2019: 1.6.0 - Added support for sorttype