读书人

ExtJs : Ext.data.store 中each的施用

发布时间: 2012-11-26 11:48:49 作者: rapoo

ExtJs : Ext.data.store 中each的使用技巧
store 中each()方法的使用应在load完使用,确切的说应该在on('load')事件中使用,
不懂就看一下下面的例子吧!。。。


//获得store,这里假如store里有3条记录。var i = 0;var ds = grid.getStore();\\//以下是正确与不正确的例子1)错误例子ds.each(function(rec){ i++; });result : i = 0;//表明each没有执行或此方法在数据加载前执行(后者的可能行更大)2)正确例子ds.on('load',function(store,records){store.each(function(rec){ i++; });});result: i = 3;下面看一下如何使grid中的checkBox为选中状态var sm = grid.getSelectionModel();//get the seletion modelds.on('load',function(store,records){store.each(function(rec) {//判断条件if(....){ sm.selectRecords([rec]); });});
1 楼 vuens 2008-06-16 非常不错,学习了。 2 楼 lyo 2008-07-14 不错不错~ 3 楼 rocky10000 2008-10-08 不错,正是我想要的。谢谢。

读书人网 >JavaScript

热点推荐