@@ -2,39 +2,34 @@ import React, { useRef } from 'react';
22import ReactDOM from 'react-dom/client' ;
33import './index.css' ;
44
5- import { IgrGridModule , IgrRowDragEndEventArgs } from 'igniteui-react-grids' ;
5+ import { IgrRowDragEndEventArgs } from 'igniteui-react-grids' ;
66import { IgrGrid , IgrColumn } from 'igniteui-react-grids' ;
77import { CustomersData } from './CustomersData' ;
88
99import 'igniteui-react-grids/grids/themes/light/bootstrap.css' ;
1010
11- const mods : any [ ] = [
12- IgrGridModule
13- ] ;
14- mods . forEach ( ( m ) => m . register ( ) ) ;
15-
1611export default function App ( ) {
1712 const data = new CustomersData ( ) ;
1813 const rightGridRef = useRef < IgrGrid > ( null ) ;
1914
20- function onGridRowDragEnd ( evt : IgrRowDragEndEventArgs ) : void {
21- const grid = evt . target as IgrGrid ;
15+ const onGridRowDragEnd = ( evt : IgrRowDragEndEventArgs ) => {
16+ const leftGrid = evt . target as IgrGrid ;
2217 const ghostElement = evt . detail . dragDirective . ghostElement ;
2318 if ( ghostElement != null ) {
2419 const dragElementPos = ghostElement . getBoundingClientRect ( ) ;
25- const gridPosition = document . getElementById ( "rightGrid" ) . getElementsByTagName ( "igc-grid" ) [ 0 ] . getBoundingClientRect ( ) ;
26-
20+ const gridPosition = document . getElementById ( "rightGrid" ) . getBoundingClientRect ( ) ;
21+
2722 const withinXBounds = dragElementPos . x >= gridPosition . x && dragElementPos . x <= gridPosition . x + gridPosition . width ;
2823 const withinYBounds = dragElementPos . y >= gridPosition . y && dragElementPos . y <= gridPosition . y + gridPosition . height ;
2924 if ( withinXBounds && withinYBounds ) {
30- grid . deleteRow ( evt . detail . dragData . key ) ;
25+ leftGrid . deleteRow ( evt . detail . dragData . key ) ;
3126 rightGridRef . current . addRow ( evt . detail . dragData . data ) ;
3227 }
3328 }
3429 }
3530
3631 return (
37- < div className = "container sample" >
32+ < div className = "container sample" >
3833 < div className = "container horizontal wrapper" >
3934 < IgrGrid data = { data } width = "40%" primaryKey = 'ID' autoGenerate = { false } rowDraggable = { true } onRowDragEnd = { onGridRowDragEnd } >
4035 < IgrColumn field = "ID" width = "100px" > </ IgrColumn >
@@ -64,9 +59,9 @@ export default function App() {
6459 </ IgrGrid >
6560 </ div >
6661 </ div >
67- ) ;
62+ ) ;
6863}
6964
7065// rendering above component in the React DOM
7166const root = ReactDOM . createRoot ( document . getElementById ( 'root' ) ) ;
72- root . render ( < App /> ) ;
67+ root . render ( < App /> ) ;
0 commit comments