Dojo - 如何使用更新的ItemFileReadStore数据刷新组合框
问题描述:
我在Dojo中更改了组合框的ItemFileReadStore。 我的代码看起来像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"/>
我的小部件类似于道场组合框控件。我更改了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();
}
});
如果您正在修改的数据客户端,你或许应该使用ItemFileWriteStore作为安德烈建议。
编辑: grid.sort()
可用于刷新一个DataGrid作为替代grid._refresh()
(谁的行为可能会随时间而改变)
答
如何刷新ItemFileReadStore? ItemFileReadStore - 它是只读数据存储。在你的情况下,你应该使用ItemFileWriteStore。看看这个问题“dijit.form.filteringselect dynamically change options”。我想这就是你要找的。
知道的,如果dndManager连接,关闭店面不会泡到DND。在'刷新'之后,我们需要拆除dnd并重建, – mschr 2012-05-05 09:52:08