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

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

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

 

  add函数会将新的数据添加到store的末尾,这对其原有的排序方式可能造成破坏,如果希望保持有序,应使用addSorted,调用方法与add相同。

  可以使用insert方法将记录插入到指定的位置,如:1 var newRecord=new PersonRecord({name:"Tom",age:22});

1 store.insert(store.getCount(),newRecord);

 

   删除操作可以使用remove和removeAll函数,如:

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

 store.removeAll();

   修改store中的数据:

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

 

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

posted on 2010-04-28 10:20  Joshua Leung  阅读(3886)  评论(0编辑  收藏  举报

导航