PickerField
Base class used for Combo, DateField, and TimeField. Displays a picker (List, DatePicker) anchored to the 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:
//<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
Configs
113Picker
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.
The name of the element property to which the picker should size and align itself.
DOM
Float & align
Input element
Label
Layout
Misc
Other
Scrolling
Properties
87
Properties
87Class hierarchy
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.
CSS
DOM
Layout
Misc
Functions
67
Functions
67Widget 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.
| Parameter | Type | Description |
|---|---|---|
fn | function | A function to execute upon all descendant widgets.
Iteration terminates if this function returns |
deep | Boolean | Pass as |
Returns true if iteration was not aborted by a step returning false