ExtJS Store的数据访问与更新问题
更新时间:2010年04月28日 19:22:37 作者:
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来提交数据修改。
复制代码 代码如下:
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来提交数据修改。
相关文章
Extjs4.0设置Ext.data.Store传参的请求方式(默认为GET)
本教程将详细介绍下设置Ext.data.Store传参的请求方式;亮点,设置请求方式,默认为GET,感兴趣的朋友可以参考下哈2013-04-04
关于viewport,Ext.panel和Ext.form.panel的关系
那个深入浅出ext作者比我还懒 viewport存放Ext.panel对象,其容器中的成员可以以borderlayout方式布局2009-05-05


最新评论