GRID drag-and-drop row instance code _ javascript skills

Source: Internet
Author: User
This article introduces the example code of GRID drag-and-drop. If you need it, please refer to --------------------- drag-and-drop an instance code line of GRID drag-and-drop ---------------------------------------

The Code is as follows:


// Create the first GRID
Var firstGrid = new Ext. grid. GridPanel ({
DdGroup: 'secondgridddgroup', // This is the ddGroup of the second GRID.
Store: firstGridStore,
EnableDragDrop: true, // True indicates that the drag action of the row selected in the GridPanel is enabled.
...... Other attributes are omitted
});

// Create the second GRID
Var secondGrid = new Ext. grid. GridPanel ({
DdGroup: 'firstgridddgroup', // This is the ddGroup of the first grid.
Store: secondGridStore,
EnableDragDrop: true, // True indicates that the drag action of the row selected in the GridPanel is enabled.
...... Other attributes are omitted
});

// Create the ddGroup OF THE FIRST GRID
Var firstGridDropTargetEl = firstGrid. getView (). el. dom. childNodes [0]. childNodes [1];
Var firstGridDropTarget = new Ext. dd. DropTarget (firstGridDropTargetEl ,{
DdGroup: 'firstgridddgroup', // It is the same as the ddGroup of the second GRID.
Copy: true,
Yydrop: function (ddSource, e, data ){
Function addRow (record, index, allItems ){
Var foundItem = secondGridStore. find ('name', record. data. name );
If (foundItem =-1 ){
FirstGridStore. add (record );
FirstGridStore. sort ('name', 'asc ');
DdSource. grid. store. remove (record );
}
}
Ext. each (ddSource. dragData. selections, addRow );
Return (true );
}
)};

// Create the ddGroup of the second GRID
Var secondGridDropTargetEl = secondGrid. getView (). el. dom. childNodes [0]. childNodes [1];
Var secondGridDropTarget = new Ext. dd. DropTarget (secondGridDropTargetEl ,{
DdGroup: 'secondgridddgroup', // It is the same as the ddGroup of the first grid.
Copy: true,
Yydrop: function (ddSource, e, data ){
Function addRow (record, index, allItems ){
Var foundItem = secondGridStore. find ('name', record. data. name );
If (foundItem =-1 ){
SecondGridStore. add (record );
SecondGridStore. sort ('name', 'asc ');
DdSource. grid. store. remove (record );
}
}
Ext. each (ddSource. dragData. selections, addRow );
Return (true );
}
});

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.