v7.3.0
SupportExamplesFree Trial

Combo
Widget

Combo (dropdown) widget. Consists of a text field with a trigger icon, which displays a List. Can be populated from a Store.

new Combo({ items : ['Fanta', 'Loranga', 'Jaffa', 'Zingo', 'Orangina'], label : 'Soda', labelPosition : 'above', placeholder : 'Select a soda', appendTo : targetElement });

Please be aware that when populating the Combo with objects or records, you have to configure valueField and displayField to point to the correct field names in your data.

This field can be used as an editor for the Column.

Basic scenarios

// combo with string items new Combo({ labelPosition : 'above', items : ['Fanta', 'Loranga', 'Jaffa', 'Zingo', 'Orangina'], label : 'Items as strings', appendTo : targetElement }); // combo with object items new Combo({ labelPosition : 'above', items : [{ value : 'pepsi', text : 'Pepsi' }, { value : 'coke', text : 'Coca Cola' }], label : 'Items as objects', appendTo : targetElement }); // non-editable combo (user can only pick from list) new Combo({ labelPosition : 'above', items : [{ value : 'MtnDew', text : 'Mountain Dew' }, 'Sprite', '7up'], label : 'Not editable', editable : false, appendTo : targetElement }); // editable combo (user can type to filter) new Combo({ labelPosition : 'above', items : ['Captain America', 'Hulk', 'She-Hulk', 'Hawkeye'], label : 'Editable', editable : true, appendTo : targetElement });

Loading data from simple string array:

Filtering on typing will still work when non-editable. The characters typed are collected and used to filter the list of items in the picker. The typed value expires after 2 seconds of inactivity. This is useful when a non-editable Combo has a very large dataset and you want to filter it by typing.

The combo's configured primaryFilter is used which uses the startsWith operator by default.

Basic scenarios

new Combo({ items : ['Fanta', 'Loranga', 'Jaffa', 'Zingo', 'Orangina'], label : 'Soda', labelPosition : 'above', placeholder : 'Select a soda', appendTo : targetElement });

Strict picker width matching

By default, a Combo's picker, auto widths around its visible content, but will be at least the width of the Combo's input area. See the first example above.

To enforce strict width matching of the picker to the input area, configure the combo's picker like this

const combo = new Combo({
    items       : ['Small', 'Mediunm', 'Large', 'Ridiculously huge which would cause a very wide dropdown'],
    placeholder : 'Pick size of diamond for ring',
    picker : {
        align : {
            // Override default which is 'min'
            matchSize : true
        }
    }
});

Autocomplete / Type ahead

Implementing remote type-ahead functionality is simple, configure a store with readUrl and define the minChars required to type before remote loading is triggered.

// Type-ahead combo list with remotely loaded data new Combo({ appendTo : targetElement, label : 'Countries', minChars : 2, displayField : 'name', valueField : 'code', filterParamName : 'filter', store : { readUrl : 'remotecombo' } }); const countries = [ { name : 'Afghanistan', code : 'AF' }, { name : 'Ă…land Islands', code : 'AX' }, { name : 'Albania', code : 'AL' }, { name : 'Algeria', code : 'DZ' }, { name : 'American Samoa', code : 'AS' }, { name : 'AndorrA', code : 'AD' }, { name : 'Angola', code : 'AO' }, { name : 'Anguilla', code : 'AI' }, { name : 'Antarctica', code : 'AQ' }, { name : 'Antigua and Barbuda', code : 'AG' }, { name : 'Argentina', code : 'AR' }, { name : 'Armenia', code : 'AM' }, { name : 'Aruba', code : 'AW' }, { name : 'Australia', code : 'AU' }, { name : 'Austria', code : 'AT' }, { name : 'Azerbaijan', code : 'AZ' }, { name : 'Bahamas', code : 'BS' }, { name : 'Bahrain', code : 'BH' }, { name : 'Bangladesh', code : 'BD' }, { name : 'Barbados', code : 'BB' }, { name : 'Belarus', code : 'BY' }, { name : 'Belgium', code : 'BE' }, { name : 'Belize', code : 'BZ' }, { name : 'Benin', code : 'BJ' }, { name : 'Bermuda', code : 'BM' }, { name : 'Bhutan', code : 'BT' }, { name : 'Bolivia', code : 'BO' }, { name : 'Bosnia and Herzegovina', code : 'BA' }, { name : 'Botswana', code : 'BW' }, { name : 'Bouvet Island', code : 'BV' }, { name : 'Brazil', code : 'BR' }, { name : 'British Indian Ocean Territory', code : 'IO' }, { name : 'Brunei Darussalam', code : 'BN' }, { name : 'Bulgaria', code : 'BG' }, { name : 'Burkina Faso', code : 'BF' }, { name : 'Burundi', code : 'BI' }, { name : 'Cambodia', code : 'KH' }, { name : 'Cameroon', code : 'CM' }, { name : 'Canada', code : 'CA' }, { name : 'Cape Verde', code : 'CV' }, { name : 'Cayman Islands', code : 'KY' }, { name : 'Central African Republic', code : 'CF' }, { name : 'Chad', code : 'TD' }, { name : 'Chile', code : 'CL' }, { name : 'China', code : 'CN' }, { name : 'Christmas Island', code : 'CX' }, { name : 'Cocos (Keeling) Islands', code : 'CC' }, { name : 'Colombia', code : 'CO' }, { name : 'Comoros', code : 'KM' }, { name : 'Congo', code : 'CG' }, { name : 'Congo, The Democratic Republic of the', code : 'CD' }, { name : 'Cook Islands', code : 'CK' }, { name : 'Costa Rica', code : 'CR' }, { name : 'Cote D\'Ivoire', code : 'CI' }, { name : 'Croatia', code : 'HR' }, { name : 'Cuba', code : 'CU' }, { name : 'Cyprus', code : 'CY' }, { name : 'Czech Republic', code : 'CZ' }, { name : 'Denmark', code : 'DK' }, { name : 'Djibouti', code : 'DJ' }, { name : 'Dominica', code : 'DM' }, { name : 'Dominican Republic', code : 'DO' }, { name : 'Ecuador', code : 'EC' }, { name : 'Egypt', code : 'EG' }, { name : 'El Salvador', code : 'SV' }, { name : 'Equatorial Guinea', code : 'GQ' }, { name : 'Eritrea', code : 'ER' }, { name : 'Estonia', code : 'EE' }, { name : 'Ethiopia', code : 'ET' }, { name : 'Falkland Islands (Malvinas)', code : 'FK' }, { name : 'Faroe Islands', code : 'FO' }, { name : 'Fiji', code : 'FJ' }, { name : 'Finland', code : 'FI' }, { name : 'France', code : 'FR' }, { name : 'French Guiana', code : 'GF' }, { name : 'French Polynesia', code : 'PF' }, { name : 'French Southern Territories', code : 'TF' }, { name : 'Gabon', code : 'GA' }, { name : 'Gambia', code : 'GM' }, { name : 'Georgia', code : 'GE' }, { name : 'Germany', code : 'DE' }, { name : 'Ghana', code : 'GH' }, { name : 'Gibraltar', code : 'GI' }, { name : 'Greece', code : 'GR' }, { name : 'Greenland', code : 'GL' }, { name : 'Grenada', code : 'GD' }, { name : 'Guadeloupe', code : 'GP' }, { name : 'Guam', code : 'GU' }, { name : 'Guatemala', code : 'GT' }, { name : 'Guernsey', code : 'GG' }, { name : 'Guinea', code : 'GN' }, { name : 'Guinea-Bissau', code : 'GW' }, { name : 'Guyana', code : 'GY' }, { name : 'Haiti', code : 'HT' }, { name : 'Heard Island and Mcdonald Islands', code : 'HM' }, { name : 'Holy See (Vatican City State)', code : 'VA' }, { name : 'Honduras', code : 'HN' }, { name : 'Hong Kong', code : 'HK' }, { name : 'Hungary', code : 'HU' }, { name : 'Iceland', code : 'IS' }, { name : 'India', code : 'IN' }, { name : 'Indonesia', code : 'ID' }, { name : 'Iran, Islamic Republic Of', code : 'IR' }, { name : 'Iraq', code : 'IQ' }, { name : 'Ireland', code : 'IE' }, { name : 'Isle of Man', code : 'IM' }, { name : 'Israel', code : 'IL' }, { name : 'Italy', code : 'IT' }, { name : 'Jamaica', code : 'JM' }, { name : 'Japan', code : 'JP' }, { name : 'Jersey', code : 'JE' }, { name : 'Jordan', code : 'JO' }, { name : 'Kazakhstan', code : 'KZ' }, { name : 'Kenya', code : 'KE' }, { name : 'Kiribati', code : 'KI' }, { name : 'Korea, Democratic People\'S Republic of', code : 'KP' }, { name : 'Korea, Republic of', code : 'KR' }, { name : 'Kuwait', code : 'KW' }, { name : 'Kyrgyzstan', code : 'KG' }, { name : 'Lao People\'S Democratic Republic', code : 'LA' }, { name : 'Latvia', code : 'LV' }, { name : 'Lebanon', code : 'LB' }, { name : 'Lesotho', code : 'LS' }, { name : 'Liberia', code : 'LR' }, { name : 'Libyan Arab Jamahiriya', code : 'LY' }, { name : 'Liechtenstein', code : 'LI' }, { name : 'Lithuania', code : 'LT' }, { name : 'Luxembourg', code : 'LU' }, { name : 'Macao', code : 'MO' }, { name : 'Macedonia, The Former Yugoslav Republic of', code : 'MK' }, { name : 'Madagascar', code : 'MG' }, { name : 'Malawi', code : 'MW' }, { name : 'Malaysia', code : 'MY' }, { name : 'Maldives', code : 'MV' }, { name : 'Mali', code : 'ML' }, { name : 'Malta', code : 'MT' }, { name : 'Marshall Islands', code : 'MH' }, { name : 'Martinique', code : 'MQ' }, { name : 'Mauritania', code : 'MR' }, { name : 'Mauritius', code : 'MU' }, { name : 'Mayotte', code : 'YT' }, { name : 'Mexico', code : 'MX' }, { name : 'Micronesia, Federated States of', code : 'FM' }, { name : 'Moldova, Republic of', code : 'MD' }, { name : 'Monaco', code : 'MC' }, { name : 'Mongolia', code : 'MN' }, { name : 'Montserrat', code : 'MS' }, { name : 'Morocco', code : 'MA' }, { name : 'Mozambique', code : 'MZ' }, { name : 'Myanmar', code : 'MM' }, { name : 'Namibia', code : 'NA' }, { name : 'Nauru', code : 'NR' }, { name : 'Nepal', code : 'NP' }, { name : 'Netherlands', code : 'NL' }, { name : 'Netherlands Antilles', code : 'AN' }, { name : 'New Caledonia', code : 'NC' }, { name : 'New Zealand', code : 'NZ' }, { name : 'Nicaragua', code : 'NI' }, { name : 'Niger', code : 'NE' }, { name : 'Nigeria', code : 'NG' }, { name : 'Niue', code : 'NU' }, { name : 'Norfolk Island', code : 'NF' }, { name : 'Northern Mariana Islands', code : 'MP' }, { name : 'Norway', code : 'NO' }, { name : 'Oman', code : 'OM' }, { name : 'Pakistan', code : 'PK' }, { name : 'Palau', code : 'PW' }, { name : 'Palestinian Territory, Occupied', code : 'PS' }, { name : 'Panama', code : 'PA' }, { name : 'Papua New Guinea', code : 'PG' }, { name : 'Paraguay', code : 'PY' }, { name : 'Peru', code : 'PE' }, { name : 'Philippines', code : 'PH' }, { name : 'Pitcairn', code : 'PN' }, { name : 'Poland', code : 'PL' }, { name : 'Portugal', code : 'PT' }, { name : 'Puerto Rico', code : 'PR' }, { name : 'Qatar', code : 'QA' }, { name : 'Reunion', code : 'RE' }, { name : 'Romania', code : 'RO' }, { name : 'Russian Federation', code : 'RU' }, { name : 'RWANDA', code : 'RW' }, { name : 'Saint Helena', code : 'SH' }, { name : 'Saint Kitts and Nevis', code : 'KN' }, { name : 'Saint Lucia', code : 'LC' }, { name : 'Saint Pierre and Miquelon', code : 'PM' }, { name : 'Saint Vincent and the Grenadines', code : 'VC' }, { name : 'Samoa', code : 'WS' }, { name : 'San Marino', code : 'SM' }, { name : 'Sao Tome and Principe', code : 'ST' }, { name : 'Saudi Arabia', code : 'SA' }, { name : 'Senegal', code : 'SN' }, { name : 'Serbia and Montenegro', code : 'CS' }, { name : 'Seychelles', code : 'SC' }, { name : 'Sierra Leone', code : 'SL' }, { name : 'Singapore', code : 'SG' }, { name : 'Slovakia', code : 'SK' }, { name : 'Slovenia', code : 'SI' }, { name : 'Solomon Islands', code : 'SB' }, { name : 'Somalia', code : 'SO' }, { name : 'South Africa', code : 'ZA' }, { name : 'South Georgia and the South Sandwich Islands', code : 'GS' }, { name : 'Spain', code : 'ES' }, { name : 'Sri Lanka', code : 'LK' }, { name : 'Sudan', code : 'SD' }, { name : 'Suriname', code : 'SR' }, { name : 'Svalbard and Jan Mayen', code : 'SJ' }, { name : 'Swaziland', code : 'SZ' }, { name : 'Sweden', code : 'SE' }, { name : 'Switzerland', code : 'CH' }, { name : 'Syrian Arab Republic', code : 'SY' }, { name : 'Taiwan, Province of China', code : 'TW' }, { name : 'Tajikistan', code : 'TJ' }, { name : 'Tanzania, United Republic of', code : 'TZ' }, { name : 'Thailand', code : 'TH' }, { name : 'Timor-Leste', code : 'TL' }, { name : 'Togo', code : 'TG' }, { name : 'Tokelau', code : 'TK' }, { name : 'Tonga', code : 'TO' }, { name : 'Trinidad and Tobago', code : 'TT' }, { name : 'Tunisia', code : 'TN' }, { name : 'Turkey', code : 'TR' }, { name : 'Turkmenistan', code : 'TM' }, { name : 'Turks and Caicos Islands', code : 'TC' }, { name : 'Tuvalu', code : 'TV' }, { name : 'Uganda', code : 'UG' }, { name : 'Ukraine', code : 'UA' }, { name : 'United Arab Emirates', code : 'AE' }, { name : 'United Kingdom', code : 'GB' }, { name : 'United States', code : 'US' }, { name : 'United States Minor Outlying Islands', code : 'UM' }, { name : 'Uruguay', code : 'UY' }, { name : 'Uzbekistan', code : 'UZ' }, { name : 'Vanuatu', code : 'VU' }, { name : 'Venezuela', code : 'VE' }, { name : 'Viet Nam', code : 'VN' }, { name : 'Virgin Islands, British', code : 'VG' }, { name : 'Virgin Islands, U.S.', code : 'VI' }, { name : 'Wallis and Futuna', code : 'WF' }, { name : 'Western Sahara', code : 'EH' }, { name : 'Yemen', code : 'YE' }, { name : 'Zambia', code : 'ZM' }, { name : 'Zimbabwe', code : 'ZW' } ]; // Mock server endpoint for demo purposes AjaxHelper.mockUrl('remotecombo', (url, params) => { const matches = params ? countries.filter(country => StringHelper.stripDiacritics(country.name.toLowerCase()).startsWith(StringHelper.stripDiacritics(params.filter.toLowerCase()))) : countries; return { responseText : JSON.stringify({ success : true, total : matches.length, data : matches }) }; });

Snippet: Loading data from simple string array

const combo = new Combo({
    items       : ['Small', 'Smaller', 'Really small', 'Tiny'],
    placeholder : 'Pick size of diamond for ring'
});

Loading data from array with item configs:

const combo = new Combo({
    items : [{ value: 'a', text: 'First' }, { value: 'z', text: 'Last' }]
});

Loading data from store:

const combo = new Combo({
    store        : memberStore,
    valueField   : 'id',
    displayField : 'name'
});

Editability

When configured with editable : false, the field may still be operated and have a value selected from the picker.

This setting just means that the textual input field may not be edited by the UI. In this mode, the picker's displayed dataset my still be filtered by typing while the picker is visible.

The combo's configured primaryFilter is used which uses the startsWith operator by default.

Grouping the list

To group the list contents, simply group your store using groupers. You can decide if clicking a header should toggle all group children (or if it should do nothing) with the allowGroupSelect flag.

const combo = new Combo({
    width            : 400,
    displayField     : 'name',
    valueField       : 'id',
    multiSelect      : true,
    picker : {
        allowGroupSelect : false,
        // Show icon based on group name
        groupHeaderTpl   : (record, groupName) => `
            <i class="icon-${groupName}"></i>${groupName}
        `
    },
    value : [1, 4],
    store : new Store({
        fields : [
            'type'
        ],
        groupers : [
            { field : 'type', ascending : true }
        ],
        data : [
            { id : 1, name : 'pizza', type : 'food' },
            { id : 2, name : 'bacon', type : 'food' },
            { id : 3, name : 'egg', type : 'food' },
            { id : 4, name : 'Gin tonic', type : 'drinks' },
            { id : 5, name : 'Wine', type : 'drinks' },
            { id : 6, name : 'Beer', type : 'drinks' }
        ]
    })
});

This demo uses multi-selection and a grouped list:

//<code-header> CSSHelper.insertRule('.foodmenu-combo .b-chip i { margin-inline-end:0.4em }', targetElement.getRootNode()); CSSHelper.insertRule('.b-list-item-group-header { font-size:1.1em; }', targetElement.getRootNode()); CSSHelper.insertRule('.b-foodmenu-item { display:flex; flex-direction:column; align-items:flex-start; margin-inline-start:0.3em}', targetElement.getRootNode()); CSSHelper.insertRule('.b-foodmenu-item span.name { font-size:1.1em; }', targetElement.getRootNode()); CSSHelper.insertRule('.b-foodmenu-item small { display:block; color:#999; margin-top:0.3em;}', targetElement.getRootNode()); CSSHelper.insertRule('.b-foodmenu-item small { display:block; color:#999; margin-top:0.3em;}', targetElement.getRootNode()); //</code-header> // multiSelect new Combo({ appendTo : targetElement, multiSelect : true, label : 'Skills - multiSelect', value : ['Javascript', 'SQL'], items : [ 'BASIC', 'COBOL', 'FORTRAN', 'DBL', 'SQL', 'C/C++', 'Java', 'Javascript' ], width : '100%' }); new Combo({ appendTo : targetElement, width : '100%', multiSelect : true, cls : 'foodmenu-combo', style : 'margin-top:3em', label : 'Grouped list + multiSelect. Type to filter the picker when open', displayField : 'name', valueField : 'id', value : [1, 5, 9], listCls : 'grouped-combo', picker : { groupHeaderTpl : (record, groupName) => ` <i class="fa-${groupName === 'Food' ? 'pizza-slice' : groupName === 'Drinks' ? 'wine-glass' : 'utensils'}"></i>${groupName} ` }, chipView : { iconTpl : (record) => `<i class="fa-${record.icon}"></i>` }, listItemTpl : record => ` <div> <span class="name">${record.name}</span> <small>${record.calories} calories</small> </div> `, editable : false, store : { fields : [ 'type', 'calories', 'icon' ], groupers : [ { field : 'type', ascending : false } ], data : [ { id : 1, name : 'Cheese sticks', type : 'starters', calories : 312, icon : 'cheese' }, { id : 2, name : 'Fried onion rings', type : 'starters', calories : 234, icon : 'ring' }, { id : 3, name : 'Hummus', type : 'starters', calories : 532, icon : 'seedling' }, { id : 4, name : 'Fried fish', type : 'food', calories : 243, icon : 'fish' }, { id : 5, name : 'Pizza', type : 'food', calories : 687, icon : 'pizza-slice' }, { id : 6, name : 'Hamburger', type : 'food', calories : 734, icon : 'hamburger' }, { id : 7, name : 'Hot dog', type : 'food', calories : 435, icon : 'hotdog' }, { id : 8, name : 'Salad', type : 'food', calories : 112, icon : 'salad' }, { id : 9, name : 'Gin tonic', type : 'drinks', calories : 145, icon : 'glass-martini' }, { id : 10, name : 'Wine', type : 'drinks', calories : 150, icon : 'glass-wine' }, { id : 11, name : 'Soda', type : 'drinks', calories : 205, icon : 'glass-citrus' }, { id : 12, name : 'Beer', type : 'drinks', calories : 109, icon : 'beer' } ] } });

Shared Stores

More than one Combo may share a Store if they are required to draw their values from a shared data set.

The only limitation here is that the characteristics of the filter that is applied to the store by typing are inherited from the first combo. So for example, all would be caseSensitive or all case-insensitve, and all would use the same filterOperator.

In the example below, all three email address inputs use the same store of recipients.

const emailAddresses = new Store({ data : [ { id : 10, name : 'Mike McGregor', email : 'mike@facebook.com' }, { id : 11, name : 'Linda Ewans', email : 'l.evans@orange.com' }, { id : 12, name : 'Don Scott', email : 'd.scott@me.com' }, { id : 13, name : 'Karen Smith', email : 'karen.smith@oracle.com' }, { id : 14, name : 'Doug Johnson', email : 'doug.johnson@nhs.co.uk' }, { id : 15, name : 'Jenny Adams', email : 'jenny@theblock.com' }, { id : 16, name : 'Daniel Williams', email : 'dwilliams01@bofa.com' }, { id : 17, name : 'Melissa Brown', email : 'mel@parrot.com' }, { id : 18, name : 'John Jones', email : 'jjones@brynrtum.com' }, { id : 19, name : 'Jane Miller', email : 'jmiller@example.com' }, { id : 20, name : 'Theo Davis', email : 'tdavis@synergex.com' }, { id : 21, name : 'Lisa More', email : 'lisa.more@twitter.com' }, { id : 22, name : 'Adam Wilson', email : 'adam.wilson@wilson.com' }, { id : 23, name : 'Mary Taylor', email : 'mtaylor@apple.com' }, { id : 24, name : 'Barbara Anderson', email : 'eanderson@google.com' }, { id : 25, name : 'James Thomas', email : 'james.thomas@facebook.com' }, { id : 26, name : 'David Jackson', email : 'djackson@twitter.com' } ] }), comboConfig = { type : 'combo', label : 'To', multiSelect : true, store : emailAddresses, displayField : 'name', chipView : { tooltip : { cls : 'b-recipient-card', newInstance : true, forSelector : '.b-chip', getHtml : 'up.emailChipTooltip' } } }; new Panel({ appendTo : targetElement, title : 'Compose', height : 500, labelPosition : 'align-before', items : { // Three almost identical Combos to : { ...comboConfig, required : true }, cc : { ...comboConfig, label : 'CC' }, bcc : { ...comboConfig, label : 'BCC' }, // A text field for the subject subject : { type : 'textfield', label : 'Subject', onInput : 'up.onSubjectInput' }, // And the body textaera body : { type : 'textarea', label : 'Message', height : 100, required : true } }, bbar : { items : { send : { text : 'Send', onClick : 'up.onSendClick' } } }, onSendClick() { this.items.forEach(i => i.syncInvalid()); if (!this.items.every(i => i.isValid)) { Toast.show('Please complete the mandatory fields'); } else { MessageDialog.alert({ title : 'Email system', message : 'Sent' }); } }, onSubjectInput({ value }) { this.title = value || 'Subject'; }, emailChipTooltip({ tip, activeTarget }) { const person = tip.owner.getRecordFromElement(activeTarget); return { children : [{ className : 'b-recipient-card-name', text : person.name }, { className : 'b-recipient-card-email', text : person.email }] }; } });

This may be operated using the keyboard. ArrowDown opens the picker, and then ArrowDown and ArrowUp navigate the picker's options. Enter selects an active option in the picker. Escape closes the picker.

No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class
  • User can edit text in text field (otherwise only pick from attached picker)

    Has a corresponding runtime editable property.

  • allowFiltering : Booleantrue
    private

    Configure this as false to disable keyboard filtering completely

  • buildItems : Function
    private

    Provide a function that returns items to be shown in the combo's selector.

  • Configure as true to force case matching when filtering the dropdown list based upon the typed value.

  • true to clear value typed to a multiselect combo when picker is collapsed

  • Specify false to not clear value typed to a multiselect combo when an item is selected.

  • Set to true to clear this field when user empties the input element

  • Field used for item text when populating from store

  • If false, filtering will be triggered once you exceed minChars. To filter only when hitting Enter key, set this to true;

  • If the dropdown is to be populated with a filtered query to a remote server, specify the name of the parameter to pass the typed string here. By default, the string is simply sent as the value of the parameter. For special encoding, configure the combo with encodeFilterParams

  • When multiSelect is true, you may configure filterSelected as true to hide items in the dropdown when they are added to the selection. It will appear as if the requested item has "moved" into the field's ChipView.

  • By default, the picker is hidden on selection in single select mode, and remains to allow more selections when multiSelect is true. Setting this to a Boolean value can override that default.

  • Configure as true to hide the expand trigger. This is automatically set to true if remote filtering is enabled by setting the filterParamName config.

  • CSS class to add to picker

  • Configure this as true and the items display field values will be localized. The display field values need to be a locale string.

  • A key value which, when typed in a multiSelect Combo, selects the currently active item in the picker, and clears the input field ready for another match to be typed.

  • When the Combo is editable : false, keystrokes are listened for and a filter string built which filters down the visible result. After a timeout of nonEditableFilterTimeout milliseconds, the filter string is cleared.

    Has a corresponding runtime nonEditableFilterTimeout property.

  • This implies that the picker will display an anchor pointer, but also means that the picker will align closer to the input field so that the pointer pierces the pickerAlignElement

  • Width of picker, defaults to this combo's pickerAlignElement width

  • Configure this as true to reapply sorting after localizing the items.

  • Store used to populate items. Also accepts a Store config object

    Has a corresponding runtime store property.

  • triggerAction : 'all'/'last'/nullall

    How to query the store upon click of the expand trigger. Specify one of these values:

    • 'all' - Clear the filter and display the whole dataset in the dropdown.
    • 'last' - Filter the dataset using the last filter value.
    • null/any other - Use the value in the input field to filter the dataset.
  • true to cause the field to be in an invalid state while the typed filter string does not match a record in the store.

  • The initial value of this Combo box. In single select mode (default) it's a simple string value, for multiSelect mode, it should be an array of record ids.

    Has a corresponding runtime value property.

  • Custom style spec to add to element

    Has a corresponding runtime style property.

  • The default configuration for the container.

  • Element (or the id of an element) to append this widget's element to. Can be configured, or set once at runtime. To access the element of a rendered widget, see element.

    Has a corresponding runtime appendTo property.

  • Object to apply to elements dataset (each key will be used as a data-attribute on the element)

    Has a corresponding runtime dataset property.

  • A createElement config object or HTML string from which to create the Widget's element.

    Has a corresponding runtime element property.

  • Widget id, if not specified one will be generated. Also used for lookups through Widget.getById

    Has a corresponding runtime id property.

  • Element (or element id) to insert this widget before. If provided, appendTo config is ignored.

    Has a corresponding runtime insertBefore property.

  • Element (or element id) to append this widget element to, as a first child. If provided, appendTo config is ignored.

    Has a corresponding runtime insertFirst property.

  • A title to display for the widget. Only in effect when inside a container that uses it (such as TabPanel)

  • Internal listeners, that cannot be removed by the user.

  • Specify true to auto select field contents on focus

  • Show a trigger to clear field, if this field is not readOnly. The trigger is available in the triggers object under the name clear. May also be an object which configures the cleartrigger.

  • Specify true to highlight field after external value changes

  • The max number of characters for the input field

  • The min number of characters for the input field

  • Text to display in empty field.

    Has a corresponding runtime placeholder property.

  • Configure as true to indicate that a null field value is to be marked as invalid. This will optionally append a * to the field label if showRequiredIndicator is set.

    Has a corresponding runtime required property.

  • If this field is not readOnly, then setting this option means that pressing the Escape key after editing the field will revert the field to the value it had when the user focused the field. If the field is not changed from when focused, the clearable behaviour will be activated.

  • true to automatically display a * after the label for this field when it is required.

    Has a corresponding runtime showRequiredIndicator property.

  • Set to true, completely bypasses validation logic (could be userful if your field is not editable to the user).

  • Only valid if this Widget is floating and being shown through showBy.true to show a connector arrow pointing to the align target.

  • Only valid if this Widget is floating. Set to true to centre the Widget in browser viewport space.

  • Only valid if this Widget is floating or positioned. Element, Widget or Rectangle to which this Widget is constrained.

  • Set to true to move the widget out of the document flow and position it absolutely in browser viewport space.

  • scrollAction : 'hide'/'realign'/null
    Widget

    Defines what to do if document is scrolled while Widget is visible (only relevant when floating is set to true). Valid values: ´null´: do nothing, ´hide´: hide the widget or ´realign´: realign to the target if possible.

  • The Formula provider prefix currently being used

  • A list of property names to be set in the underlying input element from properties by the same name in this Field object if the value is not == null.

  • Sets the native autocomplete property of the underlying input element. For more information, please refer to MDN

  • Text alignment for the input field.

  • Sets custom attributes of the underlying input element. For more information, please refer to MDN

  • inputTag : String
    ADVANCED
    Field

    If you need to use something else than a default input element, as the input element, provide the tag name here. Please note that this is used for advanced usage only, for example when using WebComponents (custom elements), and that the configured element must fulfil the same contract as a regular input element.

  • Sets the type attribute of the underlying input element (password, hidden, date, color, etc.).

  • The width to apply to the .b-field-inner element, which encompasses the input element and any triggers. If a number is specified, px will be used.

  • Sets the native spellcheck property of the underlying input element. For more information, please refer to MDN

  • Set to false to not highlight a field as invalid while typing, to instead show it on ENTER key press or similar.

  • Label, prepended to field

    Has a corresponding runtime label property.

  • CSS class name or class names to add to any configured label

  • The width to apply to the <label> element. If a number is specified, px will be used.

  • The labels to add either before or after the input field. Each label may have the following properties:

    • html The label text.
    • align'start' or 'end' which end of the field the label should go.
    • html : String

      Label text

    • align : 'start'/'end'

      Which end of the file the label should go

  • When this widget is a child of a Container, it will by default be participating in a flexbox layout. This config allows you to set this widget's align-self style.

    Has a corresponding runtime alignSelf property.

  • When this widget is a child of a Container, it will by default be participating in a flexbox layout. This config allows you to set this widget's flex style. This may be configured as a single number or a <flex-grow> <flex-shrink> <flex-basis> format string. numeric-only values are interpreted as the flex-grow value.

    Has a corresponding runtime flex property.

  • Widget's height, used to set element style.height. Either specify a valid height string or a number, which will get 'px' appended. We recommend using CSS as the primary way to control height, but in some cases this config is convenient.

    Has a corresponding runtime height property.

  • Configure with true to make widget initially hidden.

    Has a corresponding runtime hidden property.

  • Widget's margin. This may be configured as a single number or a TRBL format string. numeric-only values are interpreted as pixels.

    Has a corresponding runtime margin property.

  • The element's maxHeight. Can be either a String or a Number (which will have 'px' appended). Note that like height, reading the value will return the numeric value in pixels.

    Has a corresponding runtime maxHeight property.

  • The elements maxWidth. Can be either a String or a Number (which will have 'px' appended). Note that like width, reading the value will return the numeric value in pixels.

    Has a corresponding runtime maxWidth property.

  • The element's minHeight. Can be either a String or a Number (which will have 'px' appended). Note that like height, reading the value will return the numeric value in pixels.

    Has a corresponding runtime minHeight property.

  • The elements minWidth. Can be either a String or a Number (which will have 'px' appended). Note that like width, reading the value will return the numeric value in pixels.

    Has a corresponding runtime minWidth property.

  • A widgets weight determines its position among siblings when added to a Container. Higher weights go further down.

  • Widget's width, used to set element style.width. Either specify a valid width string or a number, which will get 'px' appended. We recommend using CSS as the primary way to control width, but in some cases this config is convenient.

    Has a corresponding runtime width property.

  • Initial text to show in badge.

    Has a corresponding runtime badge property.

  • Event that should be considered the default action of the widget. When that event is triggered the widget is also expected to trigger an action event. Purpose is to allow reacting to most widgets in a coherent way.

  • The name of the property to set when a single value is to be applied to this Widget. Such as when used in a grid WidgetColumn, this is the property to which the column's field is applied.

  • Set to false to disable localization of this object.

  • This config object contains the defaults for the Mask created for the masked config. Any properties specified in the masked config will override these values.

  • Set to true to apply the default mask to the widget. Alternatively, this can be the mask message or a Mask config object.

  • Prevent tooltip from being displayed on touch devices. Useful for example for buttons that display a menu on click etc, since the tooltip would be displayed at the same time.

  • If you are rendering this widget to a shadow root inside a web component, set this config to the shadowRoot. If not inside a web component, set it to document.body

  • Set to false to not show the tooltip when this widget is disabled

  • Configure as true to have the picker expand upon focus enter.

  • The name of the element property to which the picker should size and align itself.

  • The class to instantiate to use as the scrollable. Defaults to Scroller.

  • The bottom CSS absolute position for this widget. If specified, the widget is implicitly configured as positionable.

  • Programmatic control over which column to start in when used in a grid layout.

    Has a corresponding runtime column property.

  • The inset-inline-start CSS absolute position for this widget. If specified, the widget is implicitly configured as positionable.

  • Set this config to false to disable batching DOM updates on animation frames for this widget. This has the effect of synchronously updating the DOM when configs affecting the rendered DOM are modified. Depending on the situation, this could simplify code while increasing time spent updating the DOM.

  • The inset-inline-end CSS absolute position for this widget. If specified, the widget is implicitly configured as positionable.

  • Programmatic control over how many columns to span when used in a grid layout.

    Has a corresponding runtime span property.

  • top : Number/String
    internal
    Widget

    The top CSS absolute position for this widget. If specified, the widget is implicitly configured as positionable.

Properties

Properties are getters/setters or publicly accessible variables on this class
  • queryLast : String
    READONLY
    static

    A constant value for the triggerAction config to indicate that clicking the trigger should filter the dataset using the last filter query string, not the input field value.

  • isBadge : Booleantrue
    READONLY
    static
    ADVANCED
    Badge
    Identifies an object as an instance of Badge class, or subclass thereof.
  • isCombo : Booleantrue
    READONLY
    static
    ADVANCED
    Identifies an object as an instance of Combo class, or subclass thereof.
  • isDelayable : Booleantrue
    READONLY
    static
    ADVANCED
    Delayable
    Identifies an object as an instance of Delayable class, or subclass thereof.
  • isEvents : Booleantrue
    READONLY
    static
    ADVANCED
    Events
    Identifies an object as an instance of Events class, or subclass thereof.
  • isFormulaField : Booleantrue
    READONLY
    static
    ADVANCED
    FormulaField
    Identifies an object as an instance of FormulaField class, or subclass thereof.
  • isKeyMap : Booleantrue
    READONLY
    static
    ADVANCED
    KeyMap
    Identifies an object as an instance of KeyMap class, or subclass thereof.
  • isLabelable : Booleantrue
    READONLY
    static
    ADVANCED
    Labelable
    Identifies an object as an instance of Labelable class, or subclass thereof.
  • isLocalizable : Booleantrue
    READONLY
    static
    ADVANCED
    Localizable
    Identifies an object as an instance of Localizable class, or subclass thereof.
  • isRTL : Booleantrue
    READONLY
    static
    ADVANCED
    RTL
    Identifies an object as an instance of RTL class, or subclass thereof.
  • isValidatable : Booleantrue
    READONLY
    static
    ADVANCED
    Validatable
    Identifies an object as an instance of Validatable class, or subclass thereof.
  • properties : Object
    internal
    static
    Base

    A class property getter for the default values of internal properties for this class.

  • all : Widget[]
    internal
    READONLY
    static
    Widget

    Returns an array containing all existing Widgets. The returned array is generated by this call and is not an internal structure.

  • focusVisible : Boolean
    internal
    READONLY
    static
    Widget

    This property yields true if the currently focused element has been reached through other means than mouse click. If the activeElement matches :focus-visible.

  • recomposeAsync : Boolean
    internal
    static
    Widget

    Get/set the recomposeAsync config for all widgets. Setting this value will set the config for all existing widgets and will be the default value for newly created widgets. Set this value to null to disable the default setting for new widgets while leaving existing widgets unaffected.

    Has a corresponding recomposeAsync config.

  • tooltip : Tooltip
    READONLY
    static
    Widget

    The shared Tooltip instance which handles tooltips which are not configured with newInstance : true.

    Has a corresponding tooltip config.

  • innerElements : (HTMLElement|DomConfig)[]
    READONLY
    ADVANCED

    Returns array of the Combo's inner HTML elements. This getter can be overridden.

  • isEmpty : Boolean
    READONLY

    Returns true if this field has no selected records.

  • When the Combo is editable : false, keystrokes are listened for and a filter string built which filters down the visible result. After a timeout of nonEditableFilterTimeout milliseconds, the filter string is cleared.

    Has a corresponding nonEditableFilterTimeout config.

  • record : Model
    READONLY

    Get selected record.

  • records : Model[]
    READONLY

    Get the selected record(s).

  • Store used to populate items. Also accepts a Store config object

    Has a corresponding store config.

  • emptyArray : Array
    internal
    READONLY
    Base

    An empty array that can be used as a default value.

  • emptyObject : Object
    internal
    READONLY
    Base

    An empty object that can be used as a default value.

  • isCombo : Booleantrue
    READONLY
    ADVANCED
    Identifies an object as an instance of Combo class, or subclass thereof.
  • isField : Booleantrue
    READONLY
    ADVANCED
    Field
    Identifies an object as an instance of Field class, or subclass thereof.
  • isPickerField : Booleantrue
    READONLY
    ADVANCED
    PickerField
    Identifies an object as an instance of PickerField class, or subclass thereof.
  • isTextField : Booleantrue
    READONLY
    ADVANCED
    TextField
    Identifies an object as an instance of TextField class, or subclass thereof.
  • isWidget : Booleantrue
    READONLY
    ADVANCED
    Widget
    Identifies an object as an instance of Widget class, or subclass thereof.
  • Element (or the id of an element) to append this widget's element to. Can be configured, or set once at runtime. To access the element of a rendered widget, see element.

    Has a corresponding appendTo config.

  • content : String
    ADVANCED
    Widget

    Set HTML content safely, without disturbing sibling elements which may have been added to the contentElement by plugins and features. When specifying html, this widget's element will also have the htmlCls added to its classList, to allow targeted styling.

  • contentElement : HTMLElement
    READONLY
    ADVANCED
    Widget

    The child element into which content should be placed. This means where html should be put, or, for Containers, where child items should be rendered.

  • Get widgets elements dataset or assign to it

    Has a corresponding dataset config.

  • Get this widget's encapsulating HTMLElement, which is created along with the widget but added to DOM at render time.

    Has a corresponding element config.

  • focusElement : HTMLElement
    READONLY
    ADVANCED
    Widget

    Get this widget's primary focus holding element if this widget is itself focusable, or contains focusable widgets.

  • focusability : Focusability
    internal
    READONLY
    Widget

    Returns an object describing the focus and keyboard navigation aspects of this widget's focusElement.

  • focusableElement : HTMLElement
    READONLY
    ADVANCED
    Widget

    Returns this widget's focusElement if that element can currently be given focus (e.g., this widget is not disabled, or hidden).

  • hasPainted : Boolean
    internal
    READONLY
    Widget

    This property is set to true after processing the initial paint for the widget. It remains false during the initial paint. The intended use for this flag is to avoid processing that will be handled by the first paint (similar to not firing events during the widget's initial configuration). If this field is true, the initial paint has already taken place, otherwise, it has yet to run. This field differs from isPainted which checks that the widget's element is attached to the DOM.

  • Get/set widgets id

    Has a corresponding id config.

  • Element (or element id) to insert this widget before. If provided, appendTo config is ignored.

    Has a corresponding insertBefore config.

  • Element (or element id) to append this widget element to, as a first child. If provided, appendTo config is ignored.

    Has a corresponding insertFirst config.

  • overflowElement : HTMLElement
    READONLY
    ADVANCED
    Widget

    The child element which scrolls if any. This means the element used by the scrollable.

  • staticClassList : DomClassList
    internal
    READONLY
    Widget

    Returns the DomClassList for this widget's class. This object should not be mutated.

  • Get/set widgets elements style. The setter accepts a cssText string or a style config object, the getter always returns a CSSStyleDeclaration

    Has a corresponding style config.

  • The input element at the heart if this field

  • Returns true if the field's input is empty

  • isValid : Boolean
    READONLY
    Field

    Returns true if the field value is valid

  • Text to display in empty field.

    Has a corresponding placeholder config.

  • Configure as true to indicate that a null field value is to be marked as invalid. This will optionally append a * to the field label if showRequiredIndicator is set.

    Has a corresponding required config.

  • true to automatically display a * after the label for this field when it is required.

    Has a corresponding showRequiredIndicator config.

  • validity : ValidityState
    private
    READONLY
    Field

    Returns the DOM ValidityState for this widget's input element, or null if there isn't one.

  • The formula typed between the parentheses in a =XXX(...) expression in the field's value if the XXX matches an available FormulaProvider.

  • keyMapElement : HTMLElement
    private
    READONLY
    KeyMap

    Override to attach the keyMap keydown event listener to something else than this.element

  • keyMapSubComponents : Object
    private
    READONLY
    KeyMap

    Override to make keyMap resolve subcomponent actions to something else than this.features.

  • Get/set this widget's align-self flexbox setting. This may be set to modify how this widget is aligned within the cross axis of a flexbox layout container.

    Has a corresponding alignSelf config.

  • Get element's offsetHeight or sets its style.height, or specified height if element no created yet.

    Has a corresponding height config.

  • Get element's margin property. This may be configured as a single number or a TRBL format string. numeric-only values are interpreted as pixels.

    Has a corresponding margin config.

  • Get/set element's maxHeight. Getter returns max-height from elements style, which is always a string. Setter accepts either a String or a Number (which will have 'px' appended). Note that like height, reading the value will return the numeric value in pixels.

    Has a corresponding maxHeight config.

  • Get/set elements maxWidth. Getter returns max-width from elements style, which is always a string. Setter accepts either a String or a Number (which will have 'px' appended). Note that like width, reading the value will return the numeric value in pixels.

    Has a corresponding maxWidth config.

  • Get/set element's minHeight. Getter returns min-height from elements style, which is always a string. Setter accepts either a String or a Number (which will have 'px' appended). Note that like height, reading the value will return the numeric value in pixels.

    Has a corresponding minHeight config.

  • Get/set elements minWidth. Getter returns min-width from elements style, which is always a string. Setter accepts either a String or a Number (which will have 'px' appended). Note that like width, reading the value will return the numeric value in pixels.

    Has a corresponding minWidth config.

  • Accessor to the Scroller which can be used to both set and read scroll information.

  • Get elements offsetWidth or sets its style.width, or specified width if element not created yet.

    Has a corresponding width config.

  • config : Object
    READONLY
    ADVANCED
    Base

    Returns a copy of the full configuration which was used to configure this object.

  • isConstructing : Boolean
    READONLY
    ADVANCED
    Base

    This property is set to true before the constructor returns.

  • isDestroying : Boolean
    READONLY
    ADVANCED
    Base

    This property is set to true on entry to the destroy method. It remains on the objects after returning from destroy(). If isDestroyed is true, this property will also be true, so there is no need to test for both (for example, comp.isDestroying || comp.isDestroyed).

  • assignedId : String
    private
    READONLY
    Widget

    Get id assigned by user (not generated id)

  • Get/sets and display badge, set to null or empty string to hide.

    Has a corresponding badge config.

  • Get/set element's disabled state. Set to 'inert' to also set the inert DOM attribute.

    Has a corresponding disabled config.

  • A singleton error tooltip which activates on hover of invalid fields. before show, it gets a reference to the field and interrogates its active error list to display as the tip content.

  • true if no id was set, will use generated id instead (widget1, ...). Toggle automatically on creation

  • This readonly property is true for normal widgets in the items of a container. It is false for special widgets such as a tbar.

  • Get/set fields label. Please note that the Field needs to have a label specified from start for this to work, otherwise no element is created.

    Has a corresponding label config.

  • Get the global LocaleHelper

  • Get the global LocaleManager

  • tab : Tab
    READONLY
    Widget

    The tab created for this widget when it is placed in a TabPanel.

    Has a corresponding tab config.

  • Determines visibility by checking if the Widget is hidden, or any ancestor is hidden and that it has an element which is visible in the DOM

  • Programmatic control over which column to start in when used in a grid layout.

    Has a corresponding column config.

  • isComposable : Boolean
    internal
    READONLY
    Widget

    Returns true if this class uses compose() to render itself.

  • overflowTwin : Widget
    internal
    READONLY
    Widget

    This widget's twin that is placed in an overflow menu when this widget has been hidden by its owner, typically a Toolbar due to overflow. The overflowTwin is created lazily by ensureOverflowTwin.

  • Programmatic control over how many columns to span when used in a grid layout.

    Has a corresponding span config.

  • Get this Widget's next sibling in the parent Container, or, if not in a Container, the next sibling widget in the same parentElement.

  • Get this Widget's parent when used as a child in a Container,

  • Get this Widget's previous sibling in the parent Container, or, if not in a Container, the previous sibling widget in the same parentElement.

Functions

Functions are methods available for calling on the class
  • onClassMixedIn( )
    internal
    static
    Base

    This optional class method is called when a class is mixed in using the mixin() method.

  • changeItems( )
    private

    Prepares items to work in attached menu (converts strings to items)

  • changePicker( )
    internal

    Creates default picker widget

  • internalOnInput( )
    private

    User types into input field in editable combo, show list and filter it.

  • onEditComplete( )
    internal

    Check if field value is valid

  • onTriggerClick( )
    private

    User clicked trigger icon, toggle list.

  • emptyCache( )
    internal
    Widget

    Clear caches, forces all calls to fromCache to requery dom. Called on render/rerender.

  • Internal function used to hook destroy() calls when using thisObj

  • Internal function used restore hooked destroy() calls when using thisObj

  • doDestroy( )
    internal
    Events

    Auto detaches listeners registered from start, if set as detachable

  • once( )
    private
    Events

    Internal function used to run a callback function after an event is triggered

  • Removes all listeners registered to this object by the application.

  • clear( )
    ASYNC
    Field

    Clears the value of this Field, and triggers the clear event.

  • Trigger event when fields input changes


    Triggers: change

  • onDisabled( )
    private
    Field

    Called when disabled state is changed. Used to add or remove 'b-invalid' class for the invalid field based on current disabled state.

  • Only valid for floating Widgets. Moves to the front of the visual stacking order.

  • Called on keyMapElement keyDown

  • finalizeInit( )
    internal
    Widget

    Called by the Base constructor after all configs have been applied.

  • Hide picker

  • Show the picker

  • Toggle the picker visibility

  • Allows using arrow keys to open/close list. Relays other keypresses to list if open.

  • This method is called following an update to the widget's rendered DOM.

  • Disable the widget

  • Enable the widget

  • Unmask the widget

Events

Events are triggered for certain actions in this class and can be listened for to react to those actions in your code
  • recompose
    ADVANCED
    Widget

    This event is fired after a widget's elements have been synchronized due to a direct or indirect call to recompose, if this results in some change to the widget's rendered DOM elements.

Event handlers

Event handlers are callbacks called as a result of certain actions in this class
  • This event is called after a widget's elements have been synchronized due to a direct or indirect call to recompose, if this results in some change to the widget's rendered DOM elements.

CSS variables

CSS variables that can be set to adjust appearance
Name Description
--b-combo-chip-font-size Font size for chipview in combo
--b-combo-chip-view-margin-block Block margin for chipview in combo
--b-combo-chip-view-min-height Minimum height for chipview in combo (to avoid it collapsing when empty)
--b-combo-chip-view-padding Padding for chipview in combo
--b-combo-filled-chip-view-padding-top
filled
Top padding for chipview in combo when using "filled" rendition
--b-combo-filled-label-before-chip-view-padding-top
filled
Top padding for chipview in combo with label displayed before and using "filled" rendition
--b-combo-outlined-chip-view-padding-top
outlined
Top padding for chipview in combo when using "outlined" rendition
--b-combo-outlined-label-before-chip-view-padding-top
outlined
Top padding for chipview in combo with label displayed before and using "outlined" rendition
type: combo

Source path

Core/widget/Combo.js

Contents