Drag Drop new index

When using the drag and drop functionality to reorder rows within a single data grid, how do i find the new row position to update back to SQL? 


1 Reply

PS Prathap Senthil Syncfusion Team June 8, 2024 02:15 AM UTC

Hi Martin,

Based on your requirements, we suggest using the
RowDropped event to find the new row position in order to achieve your goal. Please refer to the code snippet and sample below for your reference.

<SfGrid AllowRowDragAndDrop="true" DataSource="@Orders">

    <GridEvents RowDropped="RowDropHandler" TValue="Order"></GridEvents>

    <GridColumns>

    </GridColumns>

</SfGrid>

 

@code {

  

 

    public void RowDropHandler(Syncfusion.Blazor.Grids.RowDroppedEventArgs<Order> args)

    {

        var DropIndex = args.DropIndex;

    }

}


Sample: https://blazorplayground.syncfusion.com/embed/rjBTtxDGipfkolDF?appbar=true&editor=true&result=true&errorlist=true&theme=bootstrap5

Reference: https://blazor.syncfusion.com/documentation/datagrid/events#rowdropped

Regards,
Prathap Senthil


Loader.
Up arrow icon