I have a Grid-component that is populated by a call to a service, from an action in my controller. I was wondering if it is possible to do this continuously, so that it will update the grid with real-time data?
Right now, my view looks like this;
And my controller like this:
Basically, the service will provide a steady stream of updated data, causing it to be more or less real-time.. All I want to accomplish, is to refresh the grid with my new data and update the graphical elements of my template. Current template is working fine, but data is only refreshed when page is refreshed.
Right now, my view looks like this;
@model FleetMonitorModel
<
div
class
=
"span12"
>
<
legend
>Fleet Monitor</
legend
>
<
div
>
@(Html.Kendo().Grid<
FleetMonitorModel
>()
.Name("Grid")
.DataSource(ds => ds
.Ajax()
.Read(read => read.Action("Get", "FleetMonitor"))
)
.HtmlAttributes(new { style = "height:auto;" })
.AutoBind(true)
.Columns(columns =>
{
columns.Template(p => { }).ClientTemplate(" ").Width(310);
columns.Template(p => { }).ClientTemplate(" ").Width(250);
columns.Template(p => { }).ClientTemplate(" ").Width(150);
columns.Template(p => { }).ClientTemplate(" ");
columns.Template(p => { }).ClientTemplate(" ").Width(80);
})
.ClientRowTemplate(Html.Partial("_ClientRowTemplate", Model).ToHtmlString())
.Pageable()
.Sortable())
</
div
>
</
div
>
private
FleetMonitorModel Model {
get
;
set
; }
...
public
ActionResult Get([DataSourceRequest] DataSourceRequest request)
{
UnitContract[] listOfUnitsFromService = Client.GetListOfUnits(
true
);
Model =
new
FleetMonitorModel()
{
UnitDetails = GenerateUnitDetails(listOfUnitsFromService.ToList()),
Refresh =
true
};
return
Json(Model.UnitDetails.ToDataSourceResult(request));
}
}
Basically, the service will provide a steady stream of updated data, causing it to be more or less real-time.. All I want to accomplish, is to refresh the grid with my new data and update the graphical elements of my template. Current template is working fine, but data is only refreshed when page is refreshed.