簡體   English   中英

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

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

當我嘗試刷新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();

然后,我需要刷新選擇器的存儲以繼續選擇新用戶,然后按照Dojo官方文檔http://dojotoolkit.org/reference-guide/1.8/dojo/data/ItemFileReadStore.html#id3進行以下操作:

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

要么

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

上面兩種方法都不起作用,執行它們時我沒有看到AJAX請求發布到后端。 那么如何選擇重裝數據呢?

提前致謝。

我自己通過一個丑陋的黑客解決了類似的問題:

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

就我而言,我使用JsonRestStore從后端獲取數據,我建議您也這樣做。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM