Is it possible to add new row to the bottom of the grid?
3 Replies
1 reply marked as answer
JP
Jeevakanth Palaniappan
Syncfusion Team
May 4, 2021 11:19 AM UTC
Hi Gergo,
Greetings from Syncfusion support.
We have validated your query and if you want the add form to open at the bottom of the grid, you can set NewRowPosition as Bottom in GridEditSettings. But if you want to save the new record at the end of the datsource list, then we suggest you to set the corresponding index value in args.Index of OnActionBegin event of the grid. Please refer the below code snippet and the sample for your reference.
|
<SfGrid @ref="Grid" DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })">
<GridEvents TValue="Order" OnActionBegin="ActionBegin"></GridEvents>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal" NewRowPosition="NewRowPosition.Bottom"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" ValidationRules="@(new ValidationRules{ Required=true})" TextAlign="TextAlign.Right" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
@code{
public List<Order> Orders { get; set; }
SfGrid<Order> Grid { get; set; }
public void ActionBegin(ActionEventArgs<Order> args) {
if ((args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Save) && args.Action == "Add")) {
args.Index = Orders.Count();
//args.Index = (Grid.PageSettings.CurrentPage * Grid.PageSettings.PageSize) - 1;
}
}
|
Documentation :
Please get back to us if you have any other queries.
Regards,
Jeevakanth SP.
Marked as answer
GE
Gergo
May 4, 2021 06:26 PM UTC
Hi,
Nice, it works perfectly.
Best
Gergö
JP
Jeevakanth Palaniappan
Syncfusion Team
May 5, 2021 05:47 AM UTC
Hi Gergo,
Thanks for the update. Please get back to us if you have any other queries.
Regards,
Jeevakanth SP.
SIGN IN To post a reply.