perliu 2009-06-29 15:16
浏览 681
已采纳

如何判断store中的数据 发生了变化

有两个grid,分别有两个store与其对应,目前实现了表格间数据拖拽,就是官方提供的例子,dnd_grid_to_grid.js

现在有个问题,该如何判断第二个grid是否有变化呢?

例如,页面打开后,左边10条 右边5条,左右相互拖拽一条,记录数都不变,但是已经不是原来的记录了。或者从一个grid中拖走一条,再把它拖回来,相当于没变化这都怎么处理啊。

其实就是each一下,然后做下面处理:
Store2.add(record);
Store1.remove(record);

这样是自动commitChanges了么?

用getModifiedRecords得到的总是0

  • 写回答

3条回答 默认 最新

  • iteye_10013 2009-06-29 15:56
    关注

    添加和删除record是不会写入modified的,只有编辑的才会。

    就你那个例子里面,监听add和remove事件就ok了.

    Store

    add : ( Store this, Ext.data.Record[] records, Number index )

    Fires when Records have been added to the Store
    Listeners will be called with the following arguments:
    this : Store
    records : Ext.data.Record[] The array of Records added
    index : Number The index at which the record(s) were added


    remove : ( Store this, Ext.data.Record record, Number index )

    Fires when a Record has been removed from the Store
    Listeners will be called with the following arguments:
    this : Store
    record : Ext.data.Record The Record that was removed
    index : Number The index at which the record was removed

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • iteye_10013 2009-06-29 15:49
    关注

    监听store的事件,如datachanged,add,remove,update

    评论
  • iteye_10013 2009-06-29 15:50
    关注

    监听store的事件,如datachanged,add,remove,update

    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 IDEA构建失败?怎么搞
  • ¥15 求该题的simpson,牛顿科特斯matlab代码,越快越好
  • ¥30 求解,有偿,可商量价格
  • ¥15 编译arm板子的gcc
  • ¥15 C++代码报错问题,c++20协程
  • ¥15 c++图Djikstra算法求最短路径
  • ¥15 Linux操作系统中的,管道通信问题
  • ¥15 ansible tower 卡住
  • ¥15 等间距平面螺旋天线方程式
  • ¥15 通过链接访问,显示514或不是私密连接