所以当存储数据发生变化时,我正在尝试刷新Datagrid。
//Store for my datagrid
var myStore= new dojo.data.ItemFileWriteStore({ url : '/my/store.html', clearOnClose:true, urlPreventCache:true } );
当我进行ajax调用以保存/更新网格数据时,在ajax调用的回调函数中我调用:
function myCallBack()
{
myStore.close();
Alert("Data Saved Successfully");
}
更新Grid中记录的函数,在退出之前调用 myStore.save()。 这种情况在FireFox中运行良好,但网格在IE8中没有刷新
非常感谢任何指针或帮助。
答案 0 :(得分:2)
好的,我找到了解决方案。首先需要关闭网格上的商店:
myGrid.myStore.close();
然后使用新数据将商店设置回网格:
myGrid.setStore(newStoreData);
有关详细信息,请关注this
答案 1 :(得分:2)
您还可以重置查询以便再次执行。按照教程设置页面:http://dojotoolkit.org/documentation/tutorials/1.7/store_driven_grid/
在具有内存存储的示例数据网格中:
require( ["dojox/grid/DataGrid", "dojo/data/ObjectStore", "dojo/store/Memory", "dojo/domReady!"],
function ( DataGrid, ObjectStore, Memory ) {
var formsList = [
{id:1, name:"Jim", department:"accounting"},
{id:2, name:"Rosenblumentalovitsch", department:"engineering"},
{id:3, name:"Mike", department:"sales"},
{id:4, name:"John", department:"sales"}
];
formStore = new Memory( {data:formsList, idProperty:"id"} );
formGrid = new DataGrid( {
store:dataStore = ObjectStore( {objectStore:formStore} ),
query: {id: "*"} ,
structure:[
{ name:"Form", field:"name", width:"100%" }
]
}, "grid" );
formGrid.startup();
} );
向formStore
添加元素时,数据网格不会自动刷新。这是带有refresh的addForm函数:
function addForm( evt ) {
// set the properties for the new item:
var myNewItem = {id:5, name:"Jim 2", department:"accounting"};
// Insert the new item into the store:
formStore.add( myNewItem );
formGrid.setQuery({id: "*"}); //this row executes the query again, thus refreshing the data grid
}