Extjs3.3.1 實現翻頁後,可記錄已經選擇的選項
阿新 • • 發佈:2019-01-22
第一步:定義記錄選擇選項變數:
var collection=new Ext.util.MixedCollection();
第二步:在store的lisenters屬性上新增兩個event. 如下:
第三步:在girdpanel的CheckboxSelectionModel上新增兩個事件.如下load:function(store, records, options){ //check recode chose var sm = grid.getSelectionModel(); store.each(function(rec) { if (collection.containsKey(rec.get("uid"))) { sm.selectRecords([rec], true); } }); }, beforeload : function(store,options){ var sm = grid.getSelectionModel(); store.each(function(rec) { if (sm.isSelected(rec)) { collection.add(rec.get("uid"),{id:rec.get("uid"),name:rec.get("account")}); } else { collection.removeKey(rec.get("uid")); } }); }
listeners:{
rowselect:function(sm, rowIndex, rec){
collection.add(rec.get("uid"),{id:rec.get("uid"),name:rec.get("account")});
},
rowdeselect : function(sm, rowIndex,rec ){
collection.removeKey(rec.get("uid"));
}
}
如上,我們的問題就可以得到圓滿的實現