我是用Ext.grid.CheckboxSelectionModel()怎样在grid加载完后只设定某行的checkbox不能选?用lock()只会整个gird不能选谢谢

解决方案 »

  1.   

    CheckboxSelectionModel的
    beforerowselect事件,返回false取消选择
      

  2.   


    var sm = new Ext.grid.CheckboxSelectionModel({
    dataIndex:"id",
    listeners:{'beforerowselect': function( SelectionModel, rowIndex, keepExisting,record ) {
            if($.trim(record.data.ReleaseFlag)=='0'||$.trim(record.data.ReleaseFlag)=='-'){ //用户状态不正常
            //Ext.Msg.alert("提示信息","当前记录已经发布,无法再修改或发布!");
            //SelectionModel
            return false; //不能进行选择
            }else{
            return true;
            }
            }}
    });这个是我之前做的 就是控制checkbox选择的还不明白的话 你去搜索下 extjs  beforerowselect 这个事件  里面的参数你看下介绍
      

  3.   

    重写方法
    Ext.override(Ext.grid.RowSelectionModel, {
        selectRow: function(index, keepExisting, preventViewNotify) {
            if (this.isLocked() || (index < 0 || index >= this.grid.store.getCount()) || (keepExisting && this.isSelected(index)) || (Number(this.grid.store.getAt(index).get("EditFlag")) === 0)) {//EditFlag是在数据源中指定的不可选中的标识
                return;
            }
            var r = this.grid.store.getAt(index);
            if (r && this.fireEvent('beforerowselect', this, index, keepExisting, r) !== false) {
                if (!keepExisting || this.singleSelect) {
                    this.clearSelections();
                }
                this.selections.add(r);
                this.last = this.lastActive = index;
                if (!preventViewNotify) {
                    this.grid.getView().onRowSelect(index);
                }
                this.fireEvent('rowselect', this, index, r);
                this.fireEvent('selectionchange', this);
            }
        }
    });
      

  4.   

    谢谢你的方法
    beforerowselect方法可以控制不能选,但同时gird rowdblclick事件就不会发生,因为我的rowdblclick事件会弹出视窗修改资料,又不想纪录的checkbox被选,被选的纪录用作提交id去删除还有什么方法令到checkbox不能选,而又能够rowdblclick?