How to get group column value when a row is dragged and dropped between groups

Hello,

I Have a Datagrid with   allowGrouping="true" and    allowRowDragAndDrop="true" , is it possible after a row is dropped to a group to get this Group column value , so we can update rows respective key ?


Thank you !


1 Reply

SI Santhosh Iruthayaraj Syncfusion Team November 9, 2023 11:32 AM UTC

Hi Panagiotis Mavrakis,


We apologize for the delayed response.


From you query, we understand that you want to get the Caption row value of the Dropped row. You can achieve this by using the "rowDrop" event. We have prepared a code snippet for your reference, which can be found below:


[CSHTML]

 

<script>

function rowDrop {

  // Get the drop target row

  var targetElement = e.target.closest('.e-row');

 

  // Start from the previous sibling of the target element

  if (targetElement) {

    var previousSibling = targetElement.previousSibling;

 

    // Loop through previous siblings until you find an element with class "e-groupcaptionrow"

    while (

      previousSibling &&

      !previousSibling.classList.contains('e-groupcaptionrow')

    ) {

      previousSibling = previousSibling.previousElementSibling;

    }

    if (previousSibling) {

      let droppedColumnValue =

        previousSibling.lastChild.innerText.split(/[:\-]/)[1];

 

      console.log(droppedColumnValue);

    }

  }

};

</script>

 


rowDrop event API: https://help.syncfusion.com/cr/aspnetcore-js2/Syncfusion.EJ2.Grids.Grid.html#Syncfusion_EJ2_Grids_Grid_RowDrop


Please feel free to reach out if you have any further questions.


Regards,

Santhosh I


Loader.
Up arrow icon