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 model
ds.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
不错,正是我想要的。谢谢。