Your search did not match any results.

This example demonstrates real-time data update in the DataGrid widget bound to a SignalR server. Note that data used in this demo is for demonstration purposes only.

Copy to CodePen
Apply
Reset
var DemoApp = angular.module('DemoApp', ['dx']); DemoApp.controller('DemoController', function DemoController($scope) { var arrayStore; $scope.dataGridOptions = { twoWayBindingEnabled: false, showBorders: true, bindingOptions: { dataSource: { deep: false, dataPath: 'dataSource' } }, onInitialized: function(e) { e.component.beginCustomLoading(); }, columns: [{ dataField: "LastUpdate", dataType: "date", width: 115, format: "longTime" }, { dataField: "Symbol" }, { dataField: "Price", dataType: "number", format: "#0.####", cellTemplate: "priceCellTemplate" }, { dataField: "Change", dataType: "number", width: 140, format: "#0.####", cellTemplate: "changeCellTemplate" }, { dataField: "DayOpen", dataType: "number", format: "#0.####" }, { dataField: "DayMin", dataType: "number", format: "#0.####" }, { dataField: "DayMax", dataType: "number", format: "#0.####" }], loadPanel: { enabled: false } }; $.connection.hub.url = "https://js.devexpress.com/Demos/Mvc/signalr"; var hub = $.connection.liveUpdateSignalRHub; hub.client.updateStockPrice = function (data) { if (arrayStore) { arrayStore.update(data.Symbol, data); $scope.dataSource.reload(); } }; $.connection.hub.start({ waitForPageLoad: false }).done(function () { hub.server.getAllStocks().done(function (data) { arrayStore = new DevExpress.data.ArrayStore({ key: "Symbol", data: data }); $scope.dataSource = new DevExpress.data.DataSource({ store: arrayStore }); $scope.$apply(); }); }); });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <script src="js/signalr/jquery.signalR-2.2.2.js"></script> <script src="js/signalr/signalr-hub.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/18.1.6/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/18.1.6/css/dx.light.css" /> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js"></script> <script>window.angular || document.write(decodeURIComponent('%3Cscript src="js/angular.min.js"%3E%3C\/script%3E'))</script> <script src="https://cdn3.devexpress.com/jslib/18.1.6/js/dx.all.js"></script> <link rel="stylesheet" type ="text/css" href ="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container" ng-app="DemoApp" ng-controller="DemoController"> <div id="gridContainer" dx-data-grid="dataGridOptions" dx-item-alias="cell"> <div data-options="dxTemplate:{ name:'priceCellTemplate' }" ng-class="{ inc: cell.data.Change > 0, dec: cell.data.Change < 0 }" class="ng-hide" ng-show="true"> <span>{{cell.text}}</span> </div> <div data-options="dxTemplate:{ name:'changeCellTemplate' }" ng-class="{ inc: cell.data.Change > 0, dec: cell.data.Change < 0 }" class="ng-hide" ng-show="true"> <span class='current-value'>{{cell.text}}</span> <span class="arrow"></span> <span class='diff'>{{cell.data.PercentChange.toFixed(2)}}%</span> </div> </div> </div> </body> </html>
#gridContainer span.current-value { display: inline-block; margin-right: 5px; } #gridContainer span.diff { width: 50px; display: inline-block; } #gridContainer .inc { color: #2ab71b; } #gridContainer .dec { color: #f00; } #gridContainer .inc .arrow, #gridContainer .dec .arrow { display: inline-block; height: 10px; width: 10px; background-repeat: no-repeat; background-size: 10px 10px; } #gridContainer .inc .arrow { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAADKSURBVHjaYtTaLs1ABEiG0nPRJa56PEHhsxBhmCUQT4OyrwHxcXyKmQgYJgHE64CYDYrXQcXIMhCbAcgWkGzgNKh38QUB0QamIUUErkhKI9ZAGyCeTERkTYaqxWsgKA2txhdG6GGsvUNGGpeBRMUiGhCFGsqGzUBQQJsxkA5AemaiG5hDIBIIgQSgK0FmMDACs549kN5FZLjhA7+A2A2U9YSAOBeLAk4gnoBDczoOcSFGPIUDPxB/wCHHiKtwYGKgMhg1cBAaCBBgAJTUIL3ToPZfAAAAAElFTkSuQmCC'); } #gridContainer .dec .arrow { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAADJSURBVHjaYvzPgBfgkhYA4o8QFahKmBioDEYNHIQGsgBxIBCLkqgvAYi/g1mMjMjir0EJzR6If/6HpChKMMgMe3DKBeIcKhiY8x/MYoDj+RQYNgdkGLqBbEB8kgzDToL1YjEQhKWB+BUJhj0H64Eahs1AELYhMpJ+gtUiGYbLQBBOI8LANLBaIg1kAAc0vkiAqSPBQFAkHcNi2DGoHMkGgrAENOCRI0ECRQ2JBoKwJTQCfkLZDPgMZPxPXN5NhtJzMSsJVBMAAgwAyWSY2svfmrwAAAAASUVORK5CYII='); }