简体   繁体   中英

How to refresh dijit/form/Select's store in Dojo?

I get a problem when I's attempting to refresh dijit/form/Select's store and to reload the data from back-end, here is my way to create dijit/form/Select:

var store = new ItemFileWriteStore({url: CONTEXT + "user/doListUsers.action"});

var selector = new Select({
    store: store,
    name: "userId",
    required: true,
    missingMessage: "You should select a user.",
    style: {
        width: "250px"
    },
    maxHeight: 300
}, "user_select");

selector.startup();

And then I need to refresh selector's store to keep selecting users are new, and I follow Dojo official's doc http://dojotoolkit.org/reference-guide/1.8/dojo/data/ItemFileReadStore.html#id3 to do this like below ways:

if (store) {
    store.close();
    store.fetch();
}

or

if (store) {
    store.url = CONTEXT + "user/doListUsers.action";
    store.close();
}

Both above methods don't work, I didn't see a AJAX request posting to back-end when I execute them. So how can I make select to reload data?

Thanks in advance.

I resolved simillar problem myself by an ugly hack:

function fetch_select_data(select){
    var store = select.store;
    select.setStore(store);
}

In my case I use JsonRestStore to fetch data from backend and I suggest you to do the same.

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