H Leonardo,Thanks for contacting Syncfusion support.Query: “I want to refresh datagrid after i add new data how can you do that ?”We have analyzed your query and we suggest you to use Refresh() method of Grid to reflect the inserted record in Grid. We would like to inform that Grid will be refreshed automatically when record is inserted using default Editing feature. We suspect that you are inserting a record in external action or using Grid Events to save record into your database. So we suggest you to use Refresh() method or assign the updated data to Grid DataSource property.If you are still facing the issue, kindly get back to us with more details about the query.Regards,Vignesh Natarajan
|
<SfButton OnClick="Record" Content="Add Record"></SfButton>
<SfButton OnClick="Refresh" Content="Refresh"></SfButton>
<SfGrid @ref="Grid" DataSource="@Orders" AllowPaging="true">
<GridPageSettings PageSize="5"></GridPageSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
@code{
SfGrid<Order> Grid { get; set; }
public static List<Order> Orders { get; set; } = new List<Order>();
public void Record()
{
Orders.Insert(0, new Order() { OrderID = Orders.Max(x => x.OrderID) + 1, CustomerID = "Added", Freight = 10, OrderDate = DateTime.Now });
}
public void Refresh()
{
Grid.Refresh();
}
|
Is it possible to do this action, and for the Grid's SfDataManager to kick off a Get request and get updated data?
Hi
Jose,
Based on your requirements, we
suggest utilizing the Grid's public method, AddRecordsAsync(),
to achieve your desired outcome. Please refer to the following code snippet and
sample
for clarification.
|
public async Task Add() { Order adddata = new Order() { OrderID = i , CustomerID = "MJDGX", ShipCountry = "LONDON", Freight = 3.01 }; await this.Grid.AddRecordAsync(adddata); i++; }
|
Regards,
Prathap s