Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

GridItemsDroppedEventArgs.GetTargetDataSourceIndexAsync() Method

Returns the suggested insertion index in the target data source.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public Task<int> GetTargetDataSourceIndexAsync()

#Returns

Type Description
Task<Int32>

The suggested index.

#Remarks

When you handle the ItemsDropped event, you can use TargetItem and DropPosition properties to define the position where to insert dropped rows. For data sources that have in-memory indices, you can call the GetTargetDataSourceIndexAsyncmethod to determine the target index automatically.

razor
<DxGrid Data="Items"
        AllowDragRows="true"
        ItemsDropped="Grid_ItemsDropped">
    <Columns>
        <DxGridDataColumn FieldName="Name" />
    </Columns>
</DxGrid>
@* ... *@
@code {
    ObservableCollection<GridDataItem> Items { get; set; }
    public record GridDataItem(string Name);
@* ... *@
    async Task Grid_ItemsDropped(GridItemsDroppedEventArgs args) {
        var droppedItem = (GridDataItem)args.DroppedItems[0];
        Items.Remove(droppedItem);
        var index = await args.GetTargetDataSourceIndexAsync();
        Items.Insert(index, droppedItem);
    }
}
See Also