ExtJS Store的数据访问与更新问题


可以使用add(Ext.data.Record[] records)或者add(Ext.data.Record record)向store末尾添加一个或多个record。如:
复制代码 代码如下:

var newRecord=new PersonRecord({name:"Tom",age:22});
store.add(newRecord);

  add函数会将新的数据添加到store的末尾,这对其原有的排序方式可能造成破坏,如果希望保持有序,应使用addSorted,调用方法与add相同。
  可以使用insert方法将记录插入到指定的位置,如:
复制代码 代码如下:

var newRecord=new PersonRecord({name:"Tom",age:22});
store.insert(store.getCount(),newRecord);

  删除操作可以使用remove和removeAll函数,如:
复制代码 代码如下:

store.remove(store.getAt(0));
store.removeAll();

  修改store中的数据:
复制代码 代码如下:

store.getAt(0).set("name","Jesse");

  修改record的内部数据之后,可以通过执行rejectChanges()来撤销所有修改,或者通过commitChanges来提交数据修改。
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3