简体   繁体   English

如何在Dojo中刷新dijit / form / Select的商店?

[英]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: 当我尝试刷新dijit / form / Select的存储并从后端重新加载数据时遇到问题,这是我创建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: 然后,我需要刷新选择器的存储以继续选择新用户,然后按照Dojo官方文档http://dojotoolkit.org/reference-guide/1.8/dojo/data/ItemFileReadStore.html#id3进行以下操作:

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. 上面两种方法都不起作用,执行它们时我没有看到AJAX请求发布到后端。 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. 就我而言,我使用JsonRestStore从后端获取数据,我建议您也这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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