I would like to know how is it possible to reflect changes made to data in grid for other users without reloading or refreshing data grid ?
I have a grid which shows product and details in Hierarchy. Now assume User A updates product A quantity how can that change be reflected for User B on the same page without reloading or refreshing grid because I don't want the datagrid to collapse for User B on every change made by other users.
I just want to show live changes on data to all users. I am using SignalR to send and receive updates but I am struggling to find a way to update grid.
Below is my hubConnection where I get notification when user modifies rows and submit on form.
rowId refers to unique guid of Product.
ProductListModel is a List
Below is my try number 1 by updating row rather then updating grid. This doesn't work and don't show update for other user (in second browser tab)
hubConnection.On<string, string>("RowUnlocked", async (rowId, module) =>
{
// Ensure the grid update is executed on the UI thread using InvokeAsync
await InvokeAsync(async () =>
{
var productToUpdate = ProductListModel.FirstOrDefault(x => x.Product_ID.ToString() == rowId);
if (productToUpdate != null)
{
await ProductDataGrid.UpdateRow(productToUpdate);
}
});
});
Below is my try number 2 which works but collapses the datagrid for other user (second tab):
It doesn't do the trick for all the browser tabs using SignalR.
I have tried when I only do Grid.Reload() I get below error when I click on row :
System.InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.
When I try with below code:
// InvokeAsync is inherited, it syncs the call back to the render thread
await InvokeAsync(() =>
{
ProductDataGrid.Reload();
});
The grid does not update without page refresh for other tabs of the browser. I know you can't help with this detail and I am struggling to make it to work. I am trying to reflect change on all browsers\tabs using SignalR without reloading page without EF. But I will share my findings if I get it to work. Thank you