现在的位置: 首页 > 综合 > 正文

store中修改数据

2019年11月17日 ⁄ 综合 ⁄ 共 563字 ⁄ 字号 评论关闭

可以使用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");


  //set()

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

抱歉!评论已关闭.