[select2] Filter the values of widget "Single Directory Suggestion"


I wish to filter dynamically the results returned by the widget “single directory suggestion” using javascript select2 class.

I saw in your tutorial we could use “inline javascript” expressions called by “Formatter Suggestion” or “Selection Formatter“. I want to be filtered through a metadata parameter data.

The Nuxeo documentation is insufficient on this subject. I can not use it properly.

I would have as a result:


type a image title


type a image title

Can we do this stuff?


1 votes

3 answers



The “Formatter Suggestion” or “Selection Formatter“ are only to format the diplayed entries and won't do any filtering.

I am not sure to understand which kind of filtering you'd like to achieve but just know that the underlying automation operation that returns the suggestions is


You might want to write your own opeartion based on it and use it by specifying its operation id to the select2 widget.

1 votes

This blog post shows how to use an Automation Script to filter suggestion results.

0 votes

First we need to create a Schema and we need to get its entries in database. Then the values that you want to show in dropdown should be written in some csv file and load it through directories-contrib.xml.

Declare your schema in core-contrib.xml like

<schema name=“FolderTypes” prefix=“medicalscholarlyarticle”

        src="schema/folder_types.xsd" />

Define your schema somewhat like

<xs:element name="id" type="xs:string"/>
<xs:element name="label_en" type="xs:string"/>
<xs:element name="obsolete" type="xs:integer" default="0"/>
<xs:element name="ordering" type="xs:integer" default="10000000"/>

and directories-contrib.xml will look like

<directory name="folder_types">

This one worked for me. Hope it resolves your problem.

-2 votes