var sm2= new Ext.grid.CheckboxSelectionModel({
singleSelect:true,
renderer:this.checkboxRenderer.createDelegate(this) //注意添加这个renderer
});
this.grid = new Ext.grid.GridPanel({//列表
border:false,
height:300,
store: ds,
cm: colModel,
sm: sm2,
});
//定义renderer
checkboxRenderer:function(value, cellmeta, record,rowIndex, columnIndex, store){
var row = this.grid.getStore().getById(record.id);
var id = row.get(this.id_key); //this.id_key 是一行的key 这样,可以根据这一行资料确定是否需要默认选择或根本就不出现选择框。
var isSelect = false;
//选中逻辑
if(!isSelect){
return '<div class="x-grid3-row-checker"> </div>';
}else{
return '';
}
},//Extjs.grid.Checkbox获值
var sm = grid.getSelectionModel();
var store = grid.getStore();
var view = grid.getView();
for(var i = 0; i < view.getRows().length; i ++){
if(sm.isSelected(i)){
var record = store.getAt(i);
var name = record.get("rec_name");
var url = record.get("rec_url");
alert(name + "," + url);
}
}
Extjs checkbox Grid勾选时事件
1. var sm = new
2. //不响应MouseDown事件
3. 'rowselect',function(sm_,rowIndex,record){//行选中的时候
4.
5. this);
6. 'rowdeselect',function(sm_,rowIndex,record){//行未选中的时候
7.
8. this);