Hi Team,
Hope all good.
I want, drag the Grid row item and drop that row item into ListBox control in-order to display the drag item column (OrderID) in ListBox control. I've tried but can't able to achieve.
|
// Grid’s rowDrop event handler
function onRowDrop(args) {
// Check if the drop target is list box
if (args.target.closest('.e-listbox-wrapper')) {
// Dropped item/items are added to the list box component
listObj.addItems(args.data);
// Dropped item/items are removed from the Grid
args.data.forEach(dat => {
grid.deleteRecord('OrderID', dat);
})
}
} |
Hi Sujith,
Thanks for your wonderful explanation. Hats off....
I have some more queries.
Query 1:
While drag and drop, I don't want the record to be deleted in Grid Control. Instead of delete I need, it to be disable the row. That means, if drag the row from grid to list box I want that the row in grid to be disabled instead of delete.
Take your example which is given in the previous response. And follow the below steps
Step 1: Drag the row from grid to list box
Actual: Note that item is deleted in grid.
Expected: That item need to be disabled.
Query 2:
I need to show below icon also! while doing the drag and drop between the list box and grid control.
Regards,
Ramesh
|
// Grid’s rowDrop event handler
function onRowDrop(args) {
if (args.target.closest('.e-listbox-wrapper')) {
listObj.addItems(args.data);
args.rows.forEach(ele => {
// The ‘e-disabled’ class will add disabled effect to the elements
// This is added to all the dropped rows
ele.classList.add('e-disabled');
})
}
} |
|
// Grid’s rowSelecting event handler
function onRowSelecting(args) {
// The row selection is cancelled if the selected row element has ‘e-disabled’ class
if (!args.row.length && args.row.classList.contains('e-disabled')) {
args.cancel = true;
} else if (args.row.length) {
args.row.forEach(ele => {
if (ele.classList.contains('e-disabled')) {
args.cancel = true;
}
})
}
} |
|
<script id="iconTemp" type="text/x-template">
<div class="e-icons e-rowcelldrag e-dtdiagonalright e-icon-rowdragicon"></div>
</script> |
|
columns: [ { headerText: 'Drag icon', template: '#iconTemp', width: 100 }, ...] |