Dojo - How to refresh combobox with updated ItemFileReadStore data

我只是一个虾纸丫 提交于 2019-12-24 09:39:43

问题


I changed ItemFileReadStore for combobox in Dojo. My code looks something like

    <span dojoType="dojo.data.ItemFileReadStore"
                jsId="comboStore"
                data="transformData">
            <select dojoType="mywidget.DropDown" id="transformCombo" value="" store="comboStore" searchAttr="name" name="state" maxHeight="100"/>

My widget is similar to dojo combobox widget. I changed transformData but the combobox is not updated until the page is entirely reloaded again. Any idea?


回答1:


If the content is changing server side and you just want to refresh your local copy of it without reloading the page, you can call fetch on the store and update your component when you receive the new data.

Here's the code that I use to refresh a dojox.grid.DataGrid when the server side content is updated:

// initialise store and link to DataGrid
var store = new dojo.data.ItemFileReadStore({
    url: "items.json",
    clearOnClose: true,
    urlPreventCache: true
});
var grid = dijit.byId("grid")
grid.setStore(store);

// code to update local copy
store.close();
store.fetch({
    onComplete: function(items, request) {
        grid._refresh();
    }
});

If you are modifying the data client side, you should probably be using ItemFileWriteStore as Andrei suggested.

Edit: grid.sort() can be used for refreshing a DataGrid as an alternative to grid._refresh() (who's behaviour may change over time)




回答2:


How do you refresh the ItemFileReadStore? ItemFileReadStore - it's read-only datastore. In your case you should use ItemFileWriteStore. Look this question " dijit.form.filteringselect dynamically change options ". I think that's what you're looking for.



来源:https://stackoverflow.com/questions/6244305/dojo-how-to-refresh-combobox-with-updated-itemfilereadstore-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!