admin管理员组文章数量:1334936
So I am trying to refresh a Datagrid when stores data changes.
//Store for my datagrid
var myStore= new dojo.data.ItemFileWriteStore({ url : '/my/store.html', clearOnClose:true, urlPreventCache:true } );
When I make an ajax call to save/update data for the grid, in callback function of ajax call I call:
function myCallBack()
{
myStore.close();
Alert("Data Saved Successfully");
}
The function that updates the records in Grid, calls myStore.save() right before exiting. This scenario works fine in FireFox but grid is not refreshing in IE8
Any pointers or help is much appreciated.
So I am trying to refresh a Datagrid when stores data changes.
//Store for my datagrid
var myStore= new dojo.data.ItemFileWriteStore({ url : '/my/store.html', clearOnClose:true, urlPreventCache:true } );
When I make an ajax call to save/update data for the grid, in callback function of ajax call I call:
function myCallBack()
{
myStore.close();
Alert("Data Saved Successfully");
}
The function that updates the records in Grid, calls myStore.save() right before exiting. This scenario works fine in FireFox but grid is not refreshing in IE8
Any pointers or help is much appreciated.
Share Improve this question asked Jun 16, 2011 at 16:10 t0mcatt0mcat 5,67919 gold badges47 silver badges58 bronze badges2 Answers
Reset to default 2Ok I found the solution. You first need to close the store on your grid:
myGrid.myStore.close();
Then set the store back to the grid with new data:
myGrid.setStore(newStoreData);
For more information, follow this
You can also reset the query in order to execute it again. Follow the tutorial in order to set up the page: http://dojotoolkit/documentation/tutorials/1.7/store_driven_grid/
in the example datagrid with an in memory store:
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();
} );
when adding an element to the formStore
the data grid is not automatically refreshed. Here is the addForm function with the refresh:
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
}
本文标签: javascriptRefresh Dojo DatagridStack Overflow
版权声明:本文标题:javascript - Refresh Dojo Datagrid - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742313620a2451367.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论