我在 Dojo 中为组合框更改了 ItemFileReadStore。 我的代码看起来像
<span dojoType="dojo.data.ItemFileReadStore"
jsId="comboStore"
data="transformData">
<select dojoType="mywidget.DropDown" id="transformCombo" value="" store="comboStore" searchAttr="name" name="state" maxHeight="100"/>
我的小部件类似于 dojo 组合框小部件。我更改了 transformData 但组合框不会更新,直到页面再次完全重新加载。有什么想法吗?
最佳答案
如果内容在服务器端发生变化,而你只想刷新它的本地副本而不重新加载页面,你可以在商店上调用 fetch
并在收到新数据时更新你的组件.
这是我在服务器端内容更新时用来刷新 dojox.grid.DataGrid 的代码:
// 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();
}
});
如果您正在修改数据客户端,您可能应该按照 Andrei 的建议使用 ItemFileWriteStore。
编辑:
grid.sort()
可用于刷新 DataGrid 作为 grid._refresh()
的替代方法(其行为可能随时间改变)
关于javascript - Dojo - 如何使用更新的 ItemFileReadStore 数据刷新组合框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6244305/