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
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 GetTargetDataSourceIndexAsync
method to determine the target index automatically.
<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