Behavior: DataList

posted May 28, 2014, 12:32 PM by Kevin Cassidy
Objects from the database can be rendered as a datalist for input fields using the "DataList" behavior:

<input type="text" class="validate-email" list="RecipientList" data-behavior="DataList" data-datalist-options="{{
    'object': 'Process',
    'objectid': '1',
    'prefix': 'Recipients',
    'field': 'MessageRecipient',
    'validate': true,
    'data': {{
        'Category': '0'

The options passed to the behavior comprise:
  • object: the parent used to invoke the 'method'
  • objectid: the parent id used to invoke the 'method'
  • minchar: when 'static' is set to false, the minimum number of characters needed to invoke the 'method'
    • Default is 1
  • display: the number of results to populate the datalist with
    • Default is 25
  • static: when set to false, will render the list dynamically based on user key strokes
    • Default is true
  • method: the method to invoke against the parent
    • Default is 'RecipientByAccess'
  • include: optional parameter passed to the 'method'
  • exclude: optional parameter passed to the 'method'
  • prefix: when a value is present will create multiple hidden elements based on the 'method' results and 'data' properties.  Used when creating multiple hidden elements which should be passed back to the server such as child classes
  • field: when 'prefix' is not specified will create a single hidden element with the value selected from the datalist
  • validate: when true will attempt to validate the field using the QBO3 validation behavior
    • Default is false
  • color: sets the background color for the token
  • data: additional hidden elements to be rendered when a datalist item is selected 
Use case:
  • Adding a message: render eligible recipients for To/Cc/Bcc addresses.