Niek Vandael
Niek Vandael

Reputation: 394

Dojo FilteringSelect: default value on async. store not visible

It seems that the default value for a dijit.form.FilteringSelect does not show on load, or when the store gets applied.

I have created a fiddle to illustrate: http://jsfiddle.net/NiekVandael/2nmz8433/3/

var fs = new dijit.form.FilteringSelect({
    store: getMyStore(),
    value: "Bar" /* Bar should be the default value */
}, 'fsNode');

Documentation: http://dojotoolkit.org/reference-guide/1.10/dijit/form/FilteringSelect.html

Any toughts?

Niek

Upvotes: 0

Views: 522

Answers (1)

frank
frank

Reputation: 3330

have you called fs.startup()?.

Here is the working jsfiddle with startup called.

edit1:

In order to set the default value you need to set the value attribute to the store Identifier field and not the display value.

var fs = new dijit.form.FilteringSelect({
        store: getMyStore(),
        value: 0 /* 0 is the identifier for the default 'Loading, Please wait 3 seconds...' will be show.n */
    }, 'fsNode');

Here is the updated jsfiddle.

Remember that the default value will be shown only once at the first time of starting up the FilteringSelect widget.

The value 'Bar' that you would like to show as default is not available at the startup. It is available only after the setTimeout function is executed. Hence it cannot be shown at the startup.

edit2:

You can set the value of the FilteringSelect widget by using the set() function of the widget. check the updated jsfiddle

Upvotes: 1

Related Questions