2011-06-16 133 views
1

因此,当存储数据发生更改时,我试图刷新Datagrid。刷新Dojo 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"); 
} 

,在网格更新记录的功能,调用myStore.save()就在退出之前。 此方案能正常工作在Firefox,但电网没有在IE8刷新

任何指针或帮助深表感谢。

回答

2

好的,我找到了解决方案。首先,您需要关闭这家商店在网格:

myGrid.myStore.close(); 

然后设定储存回用新数据网格:

myGrid.setStore(newStoreData); 

欲了解更多信息,请this

+0

不是为我工作在IE8 – 2013-06-27 17:13:32

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中的元素的数据网格不会自动刷新时。下面是刷新的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 
} 
+0

你也可以这样做formGrid.sort - 它也要求_refresh对电网。 – unludo 2012-06-12 20:18:29