简体   繁体   中英

Setting the value of FilteringSelect Dojo

I have a FilteringSelect with a jsonRest and ObjectStore

var store = new JsonRest({
        target: "categories"
});

var select = new FilteringSelect({
        store: ObjectStore({objectStore: store}),
        searchAttr: "id",
        invalidMessage : "Error"
});

The problem is when I try to set the default value, it doesn't change and makes a request to the url with the value appended. For example, if I do this:

this.select .set("value", "Hello");

it doesn't appear nothing in the select and makes a request to "categories/Hello"

Thank you

Since you are using set('value', id) , the get(id, ?options) method of the backing store is called to obtain the item so the widget has the label to display. You are using dojo/store/JsonRest , so the item ID is appended to the URL for the XHR call.

If you have the item you want to set then use set('item', item) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM