修改ext中拖拽和CheckboxSelectionModel冲突的问题

因为gridpanel定义了拖拽 所以致使选中gridpanel的数据行 就不能取消了
作如下扩展:

Ext.grid.RowSelectionModel.override(
{
// FIX: added this function so it could be overrided in CheckboxSelectionModel
handleDDRowClick: function(grid, rowIndex, e)
{
if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
this.selectRow(rowIndex, false);
grid.view.focusRow(rowIndex);
}
},

initEvents: function ()
{
if(!this.grid.enableDragDrop && !this.grid.enableDrag){
this.grid.on("rowmousedown", this.handleMouseDown, this);
}else{ // allow click to work like normal
// FIX: made this handler function overrideable
this.grid.on("rowclick", this.handleDDRowClick, this);
}

this.rowNav = new Ext.KeyNav(this.grid.getGridEl(), {
"up" : function(e){
if(!e.shiftKey){
this.selectPrevious(e.shiftKey);
}else if(this.last !== false && this.lastActive !== false){
var last = this.last;
this.selectRange(this.last, this.lastActive-1);
this.grid.getView().focusRow(this.lastActive);
if(last !== false){
this.last = last;
}
}else{
this.selectFirstRow();
}
},
"down" : function(e){
if(!e.shiftKey){
this.selectNext(e.shiftKey);
}else if(this.last !== false && this.lastActive !== false){
var last = this.last;
this.selectRange(this.last, this.lastActive+1);
this.grid.getView().focusRow(this.lastActive);
if(last !== false){
this.last = last;
}
}else{
this.selectFirstRow();
}
},
scope: this
});

var view = this.grid.view;
view.on("refresh", this.onRefresh, this);
view.on("rowupdated", this.onRowUpdated, this);
view.on("rowremoved", this.onRemove, this);
}
});

Ext.grid.CheckboxSelectionModel.override(
{
// FIX: added this function to check if the click occured on the checkbox.
// If so, then this handler should do nothing...
handleDDRowClick: function(grid, rowIndex, e)
{
var t = Ext.lib.Event.getTarget(e);
if (t.className != "x-grid3-row-checker") {
Ext.grid.CheckboxSelectionModel.superclass.handleDDRowClick.apply(this, arguments);
}
}
});

Ext.grid.GridDragZone.override(
{
getDragData: function (e)
{
var t = Ext.lib.Event.getTarget(e);
var rowIndex = this.view.findRowIndex(t);
if(rowIndex !== false){
var sm = this.grid.selModel;
// FIX: Added additional check (t.className != "x-grid3-row-checker"). It may not
// be beautiful solution but it solves my problem at the moment.
if ( (t.className != "x-grid3-row-checker") && (!sm.isSelected(rowIndex) || e.hasModifier()) ){
sm.handleMouseDown(this.grid, rowIndex, e);
}
return {grid: this.grid, ddel: this.ddel, rowIndex: rowIndex, selections:sm.getSelections()};
}

return false;
}
});
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值