简体   繁体   English

Dojo Datagrid始终显示过时的数据

[英]Dojo Datagrid always shows outdated data

I am using a Dojo Datagrid connected to a dojo.store.JsonRest through an dojo.data.ObjectStore and a dojo.store.Cache. 我正在使用通过dojo.data.ObjectStore和dojo.store.Cache连接到dojo.store.JsonRest的Dojo Datagrid。 There is also a dojo.store.Memory connected to the Cache store. 还有一个dojo.store.Memory连接到缓存存储。

The datagrid is editable with drop-downs. 该数据网格可通过下拉菜单进行编辑。 The first time a value is changed, everything seems to go fine, but if you edit the same row a second time, the edit goes through to the JsonRest and to the server, but the grid itself reverts back to displaying the old value. 第一次更改值时,一切似乎都正常,但是,如果第二次编辑同一行,则编辑将遍历JsonRest和服务器,但是网格本身将恢复为显示旧值。

Is this a known bug? 这是一个已知的错误? Any ideas for a workaround? 有任何解决方法的想法吗?

You could make the grid update row after saving your data to server. 将数据保存到服务器后,可以进行网格更新。 A callback can be like: 回调可以像这样:


function onApplyCellEditHandler(inGrid, inValue, inRowIndex, inFieldIndex) {
    inGrid.yourStore.save();
    inGrid.updateRow(inRowIndex);
}

Hope it helps 希望能帮助到你

Without seeing your code it's hard to say why the changes aren't being persisted. 没有看到您的代码,很难说为什么不保留更改。 Keep in mind that the DataGrid relies on the uniform data interface to write the changes back to the data store. 请记住,DataGrid依赖于统一数据接口将更改写回到数据存储中。 Once you have edited a cell, the changes are written back through the Dojo data adapter's setValue() method; 编辑单元格后,更改将通过Dojo数据适配器的setValue()方法写回。 unsaved changes are stored in the adapter until you call the save() method: dataStore.save(); 未保存的更改将存储在适配器中,直到您调用save()方法为止:dataStore.save(); Once save() is called, all the changes are delivered to the object store via put() calls. 调用save()后,所有更改都将通过put()调用传递到对象存储。 The thing to keep in mind is that the grid is just displaying/reflecting the data in the store. 要记住的是,网格只是在显示/反映存储中的数据。 So editing cells in the grid will not persist unless the changes have been made permanent in the underlying store(s). 因此,除非已将更改永久保留在基础存储中,否则网格中的编辑单元将不会持续。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM