Modify the conflict between drag and drop in ext and CheckboxSelectionModel.

Source: Internet
Author: User
Because gridpanel defines dragging, the data row of the selected gridpanel cannot be canceled as the following extension: Ext. grid. RowSelectionModel. override ({// FIX: addedthisfunctionsoitcouldbeoverridedinCheckboxSe...

The data row of the selected gridpanel cannot be canceled because gridpanel defines dragging.
Perform the following extensions:

Ext. grid. RowSelectionModel. override (
{
// FIX: added this function so it cocould 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 shoshould 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;
}
});

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.