Drag and Drop between different datasource grid

Hi there , doing a test to drag and drop between different tables grid i saw that the event RowDropped Is never activated or called . Is it possible to do this thing ? THX 


<SfGrid DataSource="@AddressesDataSource" ID="AddressGrid" AllowRowDragAndDrop="true" AllowSelection="true">

    <GridRowDropSettings TargetID="CustomerGrid"></GridRowDropSettings>

    <GridEvents

    RowDragStarting="RowDragStartingHandler"

    RowDropping="RowDroppingHandler"

    RowDropped="RowDroppedHandler"

    TValue="Address">

    </GridEvents>

</SfGrid>

<br />

<br />

<br />

<SfGrid DataSource="@CustomersDataSource" ID="CustomerGrid" AllowRowDragAndDrop="true" AllowSelection="true">

    <GridRowDropSettings TargetID="AddressGrid"></GridRowDropSettings>

    <GridEvents

    RowDragStarting="RowDragStartingHandler2"

    RowDropping="RowDroppingHandler2"

    RowDropped="RowDroppedHandler2"

    TValue="Customer">

    </GridEvents>

</SfGrid>


3 Replies

NP Naveen Palanivel Syncfusion Team January 3, 2025 03:51 AM UTC

Hi Francesco,

We checked your query and code, and it seems that the Grid column is generated as an autogenerated column. We would like to inform you that for performing the row drag-and-drop action on the DataGrid, one of the columns should be defined as the primary key using the IsPrimaryKey property. In the current code, the primary key is not enabled, so the drag-and-drop action does not occur, and the RowDrop event is not called or triggered. Please refer to the code snippet and sample for more information.


Reference : https://blazor.syncfusion.com/documentation/datagrid/row-drag-and-drop#drag-and-drop-events

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

<GridRowDropSettings TargetID="CustomerGrid"></GridRowDropSettings>

<GridColumns>

     <GridColumn Field="OrderID" HeaderText="Order ID" Width="120" IsPrimaryKey="true" TextAlign="TextAlign.Center" />


Regards,
Naveen



FP Francesco Pruneri January 4, 2025 07:13 AM UTC

thank you sorry now the RowDroppedHandler function is activated thank you. completely forgot to put IsPrimaryKey=‘true’ once the record is dragged to another table I will open a dialog to insert a couple of fields.

should be fine now


thanks again



NP Naveen Palanivel Syncfusion Team January 7, 2025 05:03 AM UTC

Thanks for the update, We are happy to hear that the provided information was helpful. We are closing the thread now.


Please get back to us if you have further queries.


Loader.
Up arrow icon