This is a migrated thread and some comments may be shown as answers.

Binding a Grid to SignalR AND remote datasource as fallback

1 Answer 110 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Iron
Michael asked on 17 Jun 2019, 07:49 AM

Hello,

is it possible to configure a grid with SignalR binding and binding to remote data as fallback?

For example: The grid uses SignalR to show changes using SignalR immediately. If there is a SignalR failure the grid refreshes all 10s by itself, by requesting data from the controller.

I had in mind, that i call the read method with a timer. But i have no idea how to configure the read method to do both, SignalR and reading from the controller.

Or do i have to create a second view with a Grid binding to remote data and switch the views if SignalR is not available?

 

Thanks

Michael

 

 

1 Answer, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 20 Jun 2019, 09:11 AM
Hi, Michael,

It is possible to change the grid data source runtime and replace the SignalR one with an Ajax data source by using the setDataSource() method:

https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/methods/setdatasource

It should resemble this:

// when the error occurs
 
var ajaxDataSource = new kendo.data.DataSource( {
   type: "aspnetmvc-ajax",
   "transport": {
       "read": {
           "url": "/aspnet-mvc/Grid/Customers_Read"
       }
   }
   "pageSize": 20,
   "serverPaging": true,
   "serverSorting": true,
   "serverFiltering": true,
   "serverGrouping": true,
   "serverAggregates": true,
   "schema": {
       "data": "Data",
       "total": "Total",
       "errors": "Errors",
       "model": {
           "fields": {
               "Freight": {
                   "type": "number"
               }
           }
       }
   });
   grid.setDataSource(ajaxDataSource);

For more information about the schema definition, check the article at:

https://docs.telerik.com/kendo-ui/controls/data-management/grid/editing/editing#defining-fields-through-schema

Let me know in case further questions arise.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Iron
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or