Pushing database changes to the grid from the server using SignalR

Hello,
I am trying to use the grid control with a custom adapter that uses SignalR to retrieve data.
I have followed the example on "custom adapter as a component" to pass in the SignalR data access service I have written. 
I pass the DataManagerRequest to the server and use DataOperations.execute on the server to perform filtering, sorting, pagnation etc.

It all works great, the next part I am trying to implement is pushing changes to the result set from the server to the client.
I am caching the DataManagerRequest against the SignalR connection ID, I have a SQLDependancy listening for changes to the table.
When a change is detected I am performing the DataOperations.execute again but how would I push this data to the custom adapter without it asking for it?

I was thinking of changing the binding to an ObservableCollection but this would only hold the items to display.
I could push changes to the observable collection but how would I intercept the data read requests to send the DataManagerRequest to the server?

Any help would be greatly appreciated.

Thanks

3 Replies 1 reply marked as answer

JP Jeevakanth Palaniappan Syncfusion Team October 2, 2020 12:16 PM UTC

Hi Jim, 

Greetings from Syncfusion support. 

We have checked your query and we suspect that you need to push the data to the customer adaptor by invoking the Read method of Custom adaptor. For this, we suggest you to invoke the refresh method of the grid after the data operation executed on changes detection. Please find the API reference for the refresh method of the grid. 


Incase if we misunderstood your query, kindly share us some more information about your requirement or provide us the video demonstration of the problem you are facing. 

Regards, 
Jeevakanth SP. 


Marked as answer

JI Jim October 2, 2020 06:25 PM UTC

Hi Jeevakanth,
Thank you for the reply.
Is there any way of getting to the parent sfGrid instance from the data adapter?
I was hoping to keep all of the functionality encapsulated in this rather than set up another SignalR connection in the component hosting the grid.

Thanks,
Jim


VN Vignesh Natarajan Syncfusion Team October 5, 2020 07:20 AM UTC

Hi Jim,  
 
Thanks for the update.  
 
Query: “Is there any way of getting to the parent sfGrid instance from the data adapter? 
 
We have analyzed your query and we suggest you to achieve your requirement (to get the Grid instance in CustomAdaptor component) by defining it (Grid reference) as a CascadingParameter. Refer the below code example.  
 
<SfGrid TValue="Order" ID="Grid" AllowSorting="true" AllowFiltering="true" AllowPaging="true"> 
    <SfDataManager Adaptor="Adaptors.CustomAdaptor"> 
        <CustomAdaptorComponent></CustomAdaptorComponent> 
    </SfDataManager> 
    <GridPageSettings PageSize="8"></GridPageSettings> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Center" Width="140"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn> 
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" TextAlign="@TextAlign.Center" Width="140"></GridColumn> 
    </GridColumns> 
</SfGrid> 
[CustomAdaptorComponent.razor] 
@code {    [Parameter]    [JsonIgnore]    public RenderFragment ChildContent { getset; }     [CascadingParameter]    public SfGrid<Order> ParentGrid { getset; }
 
 
Kindly get back to us if you have further queries.  
  
Regards, 
Vignesh Natarajan  


Loader.
Up arrow icon