Hello,
I am using a DataGrid with Custom Adaptor. I got the data from serverside by a controller which is filering, sorting and paging (skip and take) according DataGrid configuration.
As I have a huge amount of data to build I dont want to refresh the datagrid. So I want to refresh just the grid entry I have modified. The data is modified on serverside; I have just to refresh this one row! Another problem is that when I refresh the datagrid the selection of the currently modified item is gone, too!
I hope you can give me some hints/examples to hande this!
Thx much!
I tested grid.UpdateColumnAsync() method and its working.
Is that method intended for refreshing without reading the data from adaptor?
|
<button @onclick="Check">Checking</button>
<SfGrid @ref="Grid" DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })" Height="315">
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" ValidationRules="@(new ValidationRules { Required = true })" Type="ColumnType.Number" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" ValidationRules="@(new ValidationRules{ Required=true})" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" EditType="EditType.DatePickerEdit" Format="d" TextAlign="TextAlign.Right" Width="130" Type="ColumnType.Date"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" EditType="EditType.NumericEdit" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.ShipCountry) HeaderText="Ship Country" EditType="EditType.DropDownEdit" Width="150"></GridColumn>
</GridColumns>
</SfGrid>
@code{
SfGrid<Order> Grid { get; set; }
public async Task Check()
{
//Grid.UpdateCellAsync(2, "CustomerID", "Checked");
Order ord = Orders[2];
ord.CustomerID = "Updated";
ord.Freight = 99;
await Grid.SetRowDataAsync(ord.OrderID, ord, true);
}
|
Thx for the fast reply!
So the difference between
UpdateColumnAsync() and SetRowDataAsync() is that the SetRow is refresh just the row and UpdateColum the complete (visible) datagrid entries?
And if I want to refresh multiple entries, which method is faster? UdateColumn (if also correct) or iterate over the changed items with
Ok,
but what is the difference to UpdateColumnAsync()?
In this scenario I am just refreshing one or multiple rows with the same property/column.
I guess if I just updating one row the UpdateCell is the fastest, then SetRowData. But what is the fastest method to update multiple entries (just one property).
Sorry, my fault,
the used method is named RefreshColumnsAsync() that I am calling in the OnClick event of an icon in a GridColumn Template. In this method I am changing the value of the row(s) and after calling RefreshColumnsAsync() the grid is refreshed without calling the Adoptor.
Is this okay or do you suggest me to use UpdateCellAsync or SetRowAsync()