Select Dropdown Editor (single/multiple)
index
See the Editors - Docs for more general info about Editors (validators, event handlers, ...)
Select Editors
The library ships with two select editors: singleSelectEditor
and the multipleSelectEditor
. Both support the multiple-select library, but fallback to the bootstrap form-control style if you decide to exclude this library from your build. These editors will work with a list of foreign key values (custom structure not supported) and can be displayed properly with the collectionFormatter.
We use an external lib named multiple-select-vanilla.
Usage
Here's an example with a collection
, collectionFilterBy
and collectionSortBy
Editor Options (MultipleSelectOption
interface)
MultipleSelectOption
interface)All the available options that can be provided as editorOptions
to your column definitions via the MultipleSelectOption
interface of the external library and so you should cast your editorOptions
to that interface to make sure that you use only valid options of the Multiple-Select-Vanilla
library.
Grid Option `defaultEditorOptions
You could also define certain options as a global level (for the entire grid or even all grids) by taking advantage of the defaultEditorOptions
Grid Option. Note that they are set via the editor type as a key name (autocompleter
, date
, ...) and then the content is the same as editorOptions
(also note that each key is already typed with the correct editor option interface), for example
Complex Object
If your field
string has a dot (.) it will automatically assume that it is dealing with a complex object. There are however some options you can use with a complex object, the following options from the ColumnEditor
might be useful to you
Collection Override
In some cases you might want to provide a custom collection based on the current item data context (or any other logic), you can do that via the collection override. Also note that this override is processed after collectionFilterBy
and collectionSortBy
but before the customStructure
(if you have any), in other words make sure that the collection returned by the override does have the properties defined in the "customStructure".
Let take this example, let say that we want to allow collection values lower than or greater than 50 depending on its item Id, we could do the following
Collection Label Prefix/Suffix
You can use labelPrefix
and/or labelSuffix
which will concatenate the multiple properties together (labelPrefix
+ label
+ labelSuffix
) which will used by each Select Filter option label. You can also use the property separatorBetweenTextLabels
to define a separator between prefix, label & suffix.
Note If enableTranslateLabel
flag is set to True
, it will also try to translate the Prefix / Suffix / OptionLabel texts.
For example, say you have this collection
You can display all of these properties inside your dropdown labels, say you want to show (symbol with abbreviation and country name). Now you can.
So you can create the multipleSelect
Filter with a customStructure
by using the symbol as prefix, and country as suffix. That would make up something like this:
$ USD USA
$ CAD Canada
with a customStructure
defined as
Collection Label Render HTML
By default HTML is not rendered and the label
will simply show HTML as text. But in some cases you might want to render it, you can do so by enabling the enableRenderHtml
flag.
NOTE: this is currently only used by the Editors that have a collection
which are the MultipleSelect
& SingleSelect
Editors.
Collection Watch
Sometime you wish that whenever you change your filter collection, you'd like the filter to be updated, it won't do that by default but you could use enableCollectionWatch
for that purpose to add collection observers and re-render the Filter DOM element whenever the collection changes. Also note that using collectionAsync
will automatically watch for changes, so there's no need to enable this flag for that particular use case.
multiple-select.js
Options
multiple-select.js
OptionsYou can use any options from Multiple-Select.js and add them to your editorOptions
property. However please note that this is a customized version of the original (all original lib options are available so you can still consult the original site for all options).
Couple of small options were added to suit SlickGrid-Universal needs, which is why it points to slickgrid-universal/lib
folder (which is our customized version of the original). This lib is required if you plan to use multipleSelect
or singleSelect
Filters. What was customized to (compare to the original) is the following:
okButton
option was added to add an OK button for simpler closing of the dropdown after selecting multiple options.okButtonText
was also added for locale (i18n)
offsetLeft
option was added to make it possible to offset the dropdown. By default it is set to 0 and is aligned to the left of the select element. This option is particularly helpful when used as the last right column, not to fall off the screen.autoDropWidth
option was added to automatically resize the dropdown with the same width as the select filter element.autoAdjustDropHeight
(defaults to true), when set will automatically adjust the drop (up or down) heightautoAdjustDropPosition
(defaults to true), when set will automatically calculate the area with the most available space and use best possible choise for the drop to show (up or down)autoAdjustDropWidthByTextSize
(defaults to true), when set will automatically adjust the drop (up or down) width by the text size (it will use largest text width)to extend the previous 3 autoAdjustX flags, the following options can be helpful
minWidth
(defaults to null, to use whenautoAdjustDropWidthByTextSize
is enabled)maxWidth
(defaults to 500, to use whenautoAdjustDropWidthByTextSize
is enabled)adjustHeightPadding
(defaults to 10, to use whenautoAdjustDropHeight
is enabled), when usingautoAdjustDropHeight
we might want to add a bottom (or top) padding instead of taking the entire available spacemaxHeight
(defaults to 275, to use whenautoAdjustDropHeight
is enabled)
Code
Last updated