PickerField

Base class used for Combo, DateField, and TimeField. Displays a picker (List, DatePicker) anchored to the field.

Picker field
//<code-header>
fiddle.title = 'Picker field';
//</code-header>
const field = new PickerField({
    appendTo : targetElement,
    picker   : {
        type         : 'panel',
        scrollAction : 'realign',
        height       : '20em',
        width        : '20em',
        layout       : {
            type : 'vbox',
            gap  : 10
        },
        align : {
            align    : 't0-b0',
            axisLock : true
        },

        items : {
            high : {
                type      : 'button',
                text      : 'High',
                onClick   : 'up.onPickerClick',
                rendition : 'filled',
                color     : 'b-red'
            },
            medium : {
                type      : 'button',
                text      : 'Medium',
                onClick   : 'up.onPickerClick',
                rendition : 'filled',
                color     : 'b-blue'
            },
            low : {
                type      : 'button',
                text      : 'Low',
                onClick   : 'up.onPickerClick',
                rendition : 'filled',
                color     : 'b-gray'
            }
        },

        bbar : {
            items : {
                close : {
                    text    : 'Close',
                    onClick : 'up.onCloseClick'
                }
            }
        },

        html : '<strong> Select priority</strong>'
    },
    triggers : {
        expand : {
            cls     : 'fa fa-arrow-down',
            handler : 'onTriggerClick',
            weight  : 200
        }
    },

    onPickerClick({ selection, source }) {
        this.value = source.text;
        this.picker.hide();
    },

    onCloseClick() {
        this.hidePicker();
    }
});

This field's subclasses can be used as editors for the Column. Used by the Priority column in this demo:

Picker field as cell editor
//<code-header>
fiddle.title = 'Picker field as cell editor';
//</code-header>
class PriorityField extends PickerField {
    static $name = 'PriorityField';

    static alias = 'priority';

    static configurable = {
        picker : {
            type         : 'panel',
            scrollAction : 'realign',
            height       : '20em',
            width        : '20em',
            layout       : {
                type : 'vbox',
                gap  : 10
            },
            align : {
                align    : 't0-b0',
                axisLock : true
            },

            items : {
                high : {
                    type      : 'button',
                    text      : 'High',
                    onClick   : 'up.onPickerClick',
                    rendition : 'filled',
                    color     : 'b-red'
                },
                medium : {
                    type      : 'button',
                    text      : 'Medium',
                    onClick   : 'up.onPickerClick',
                    rendition : 'filled',
                    color     : 'b-blue'
                },
                low : {
                    type      : 'button',
                    text      : 'Low',
                    onClick   : 'up.onPickerClick',
                    rendition : 'filled',
                    color     : 'b-gray'
                }
            },

            bbar : {
                items : {
                    close : {
                        text      : 'Close',
                        rendition : 'filled',
                        onClick   : 'up.onCloseClick'
                    }
                }
            },

            html : '<strong> Select priority</strong>'
        },
        triggers : {
            expand : {
                cls     : 'fa fa-arrow-down',
                handler : 'onTriggerClick',
                weight  : 200
            }
        }
    };

    onPickerClick({ selection, source }) {
        this.value = source.text;
        this.picker.hide();
    }

    onCloseClick() {
        this.hidePicker();
    }
}

PriorityField.initClass();

// grid with basic configuration
const grid = new Grid({
    // makes grid as high as it needs to be to fit rows
    autoHeight : true,
    appendTo   : targetElement,
    columns    : [
        { text : 'Id', field : 'id', width : 40, editor : false },
        { text : 'Task', field : 'name', width : 150 },
        {
            text   : 'Priority',
            field  : 'prio',
            editor : 'priority'
        },
        { text : 'Notes', field : 'notes' }
    ],

    data : [
        { id : 1, name : 'Cook eggs', prio : 'High' },
        { id : 2, name : 'Fry bacon', prio : 'Medium' },
        { id : 3, name : 'Make salad', prio : 'Low' }
    ]
});

When focused by means of touch tapping on the trigger element (eg, the down arrow on a Combo) on a tablet, the keyboard will not be shown by default to allow for interaction with the dropdown.

A second tap on the input area will then show the keyboard if required.

Configs

113

Common

editable: Boolean= true

User can edit text in text field (otherwise only pick from attached picker)

listenersEvents

Picker

autoExpand: Boolean

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

Configuration object for the picker on initialization. Returns the picker instance at runtime.

A config object which is merged into the generated picker configuration on initialization to allow specific use cases to override behaviour. For example:

    picker: {
        align: {
            anchor: true
        }
    }

Returns the picker instance at runtime.

pickerAlignElement: String= element

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

Accessibility

ariaLabelWidget
keyMapKeyMap

Container

inlineField

CSS

clsWidget
colorWidget
htmlClsWidget
styleWidget
uiWidget

DOM

adoptWidget
appendToWidget
contentWidget
datasetWidget
htmlWidget
idWidget
tagWidget
titleWidget

Field

maxLengthTextField
minLengthTextField

Float & align

alignWidget
anchorWidget
centeredWidget
draggableWidget
floatingWidget
xWidget
yWidget

Input element

Label

hintField
labelLabelable
labelClsLabelable
labelPositionLabelable
labelsField
labelWidthLabelable

Layout

alignSelfWidget
dockWidget
flexWidget
heightWidget
hiddenWidget
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
textAlignWidget
weightWidget
widthWidget

Misc

badgeBadge
dataFieldWidget
disabledWidget
localeClassLocalizable
localizableLocalizable
maskedWidget
ownerWidget
refWidget
rippleWidget
tabWidget
tooltipWidget

Other

columnWidget
nameField
renditionTextField
rtlRTL
spanWidget
valueField

Scrolling

Properties

87

Class hierarchy

isPickerField: Boolean= truereadonly
Identifies an object as an instance of PickerField class, or subclass thereof.
isPickerField: Boolean= truereadonlystatic
Identifies an object as an instance of PickerField class, or subclass thereof.
isBadgeBadge
isDelayableDelayable
isEventsEvents
isFieldField
isFormulaFieldFormulaField
isKeyMapKeyMap
isLabelableLabelable
isLocalizableLocalizable
isTextFieldTextField
isValidatableValidatable
isWidgetWidget

Picker

Configuration object for the picker on initialization. Returns the picker instance at runtime.

A config object which is merged into the generated picker configuration on initialization to allow specific use cases to override behaviour. For example:

    picker: {
        align: {
            anchor: true
        }
    }

Returns the picker instance at runtime.

Accessibility

keyMapKeyMap

CSS

clsWidget

DOM

appendToWidget
contentWidget
datasetWidget
elementWidget
htmlWidget
idWidget
styleWidget

Float & align

xWidget
yWidget

Layout

alignSelfWidget
flexWidget
heightWidget
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
widthWidget

Lifecycle

configBase

Misc

badgeBadge
cellInfoWidget
disabledWidget
errorTipValidatable
labelLabelable
localeHelperLocalizable
localeManagerLocalizable
refWidget
tabWidget
tooltipWidget

Other

$namestaticWidget
columnWidget
formulaFormulaField
inputField
isEmptyField
isValidField
renditionTextField
rtlRTL
spanWidget
typestaticWidget
valueField

Visibility

hiddenWidget
isVisibleWidget

Widget hierarchy

ownerWidget
parentWidget

Functions

67

Picker

Hide picker

Toggle the picker visibility

Widget hierarchy

Iterate over all widgets owned by this widget and any descendants.

Note: Due to this method aborting when the function returns false, beware of using short form arrow functions. If the expression executed evaluates to false, iteration will terminate.

Due to the picker config being a lazy config and only being converted to be a List instance just before it's shown, the picker will not be part of the iteration before it has been shown once.

ParameterTypeDescription
fnfunction

A function to execute upon all descendant widgets. Iteration terminates if this function returns false.

deepBoolean

Pass as false to only consider immediate child widgets.

Returns: Boolean -

Returns true if iteration was not aborted by a step returning false

closestWidget
containsWidget
ownsWidget
queryWidget
queryAllWidget
upWidget

Configuration

applyDefaultsstaticBase

Events

Float & align

alignToWidget
setXYWidget
showByWidget
toFrontWidget

Lifecycle

createstaticWidget
destroystaticBase
initClassstaticWidget

Misc

attachTooltipstaticWidget
fromElementstaticWidget
fromSelectorstaticWidget
getByIdstaticWidget
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

clearField
clearErrorValidatable
composeWidget
createOnFrameDelayable
disableWidget
enableWidget
focusWidget
getErrorsValidatable
LstaticLocalizable
maskWidget
onEvents
recomposeWidget
relayAllEvents
selectField
setErrorValidatable
triggerEvents
unEvents
unmaskWidget

Visibility

hideWidget
showWidget

Events

19
actionField
catchAllEvents
changeField
clearField
destroyEvents
focusInWidget
focusOutWidget
hideWidget
inputField
paintWidget
readOnlyWidget
recomposeWidget
resizeWidget
showWidget
triggerField

Event handlers

19

Typedefs

7

CSS variables

124