Refresh one/some items with CustomAdaptor

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!


8 Replies 1 reply marked as answer

BP Bernd Parchmann January 13, 2022 09:12 AM UTC

I tested grid.UpdateColumnAsync() method and its working.

Is that method intended for refreshing without reading the data from adaptor?



VN Vignesh Natarajan Syncfusion Team January 13, 2022 11:06 AM UTC

Hi Bernd,  
 
Thanks for contacting Syncfusion support.  
 
Query: “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! && “I tested grid.UpdateColumnAsync() method and its working. 
 
We have analyzed your requirement and we understand that you have achieved your requirement using UpdateCellAsync not UpdateColumnAsync method of Grid. UpdateCellAsync method is used to update the cell value when edit mode is of Batch mode. This method is used to update only the one cell per time and will update the changes in batch mode only.  
 
If you want to refresh the entire record, then we suggest you to achieve your requirement SetRowDataAsync of Grid. Refer the below code example.  
 
<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 { getset; } 
  
    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); 
    } 
 
  
We request you to achieve your requirement using SetRowDataAsync method of Grid or UpDateCellAsync method of Grid if you want to update the grid in batch mode.  
 
Refer our API documentation for your reference 
 
 
Query: “Another problem is that when I refresh the datagrid the selection of the currently modified item is gone, too! 
 
We have ensured the reported issue with SetRowDataAsync method and selection is not lost. So kindly ensure the reported issue with SetRowDataAsync method and get back to us if you have further queries. 
 
If above solutions does not resolve your queries, kindly get back to us with more details about your requirement.  
 
Regards, 
Vignesh Natarajan  



BP Bernd Parchmann January 13, 2022 11:14 AM UTC

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



RS Renjith Singh Rajendran Syncfusion Team January 14, 2022 06:44 AM UTC

Hi Bernd, 
 
By default, you can update a single cell in row at a time using UpdateCellAsync method. Calling this method accepts a particular value for a single cell as argument. To update multiple cells in batch mode you can iterate the UpdateCellAsync method inside a foreach loop. We have already discussed a related topic in the below thread, please refer the below thread for more details, 
 
But you can update multiple cells of a single row at a time by calling the SetRowDataAsync method. Calling this SetRowDataAsync method accepts an entire row data as argument. We have already shared the code in our previous update, please refer the below thread for details, 
 
You can use any one of the above two methods based on your requirement. Please check this from your side and if you need further assistance, kindly share with us your complete requirement to proceed further. 
 
Regards, 
Renjith R 



BP Bernd Parchmann January 14, 2022 06:44 PM UTC

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).



RS Renjith Singh Rajendran Syncfusion Team January 17, 2022 11:45 AM UTC

Hi Bernd, 
 
Query 1 : but what is the difference to UpdateColumnAsync()? 
We would like to inform you that, we don’t have any inbuilt UpdateColumnAsync method in Grid. Are you referring the UpdateCellAsync method as UpdateColumnAsync? Or are you using any method named UpdateColumnAsync? Kindly share with us more details regarding this to proceed further. 
 
Query 2 : But what is the fastest method to update multiple entries (just one property). 
And also as informed in our previous update, UpdateCellAsync method updates only a single cell of DataGrid at a time. So to update multiple entries/cells of Grid, we suggest you to use the solution provided in our previous update to achieve this requirement. 
 
Kindly try the suggested solution and if you are facing any difficulties when applying the solution suggested from our previous update, then kindly get back to us with the following details to proceed further 
 
  1. Share the details of the problem you are facing when using the suggested solution.
  2. Share a video demo showing the detailed explanation of the problem you are facing.
  3. Share a detailed explanation of your complete requirement.
 
The provided information will help us analyze the problem, and provide you a solution as early as possible. 
 
Regards, 
Renjith R 



BP Bernd Parchmann January 17, 2022 03:37 PM UTC

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()




RS Renjith Singh Rajendran Syncfusion Team January 18, 2022 05:20 AM UTC

Hi Bernd, 
 
Thanks for your update. 
 
We could see that you are updating Grid’s DataSource and calling the RefreshColumnsAsync method to reflect the changes made in DataSource to grid for updating multiple entries. You can use the solution which you have implemented to achieve this requirement. 
 
Please get back to us if you need further assistance. 
 
Regards, 
Renjith R 


Marked as answer
Loader.
Up arrow icon