Get data by index after sortting

I am using the RowDropping event in Syncfusion Gantt, and I need to obtain the target entity. However, after sorting, the args.DropIndex does not correspond to the actual data entity. How can I use args.DropIndex to retrieve the sorted entity from the data?


1 Reply

VS Vignesh Sivalingam Syncfusion Team December 28, 2023 12:59 PM UTC

Hi Yang,


Greetings from Syncfusion.


After analyzing your query, we have comprehended that you desire to obtain the dropped record after sorting it by dropIndex in the RowDropping event. Regrettably, this cannot be achieved in the RowDropping event. However, you can fulfill this requirement by utilizing the RowDropped event. To assist you in understanding this concept better, we have created a sample with the RowDropped event. In this event, we retrieve the record from the current view record using args.DropIndex. For more detailed information, kindly refer to the code snippet and sample provided below.


Code Snippet:

public async void RoWDroppedHandler(RowDroppedEventArgs<TaskData> args)

{

    List<TaskData> record = Gantt.GetCurrentViewRecords();

    int index = args.Target.ID == "Child" ? args.DropIndex : args.DropIndex - 1;

    TaskData droppedRecord = record[index];

    droppedRecord.TaskName = "New Task";

    await Gantt.RefreshAsync();

}


Sample: Sample

Regards,

Vignesh Sivalingam


Loader.
Up arrow icon