Hi sbanerjee,
Yes, Wijmo 5 does support real time programming. You can use the ObservableArray instead of a regular JavaScript array to achieve your requirement of updating the grid with real time data. An ObservableArray updates the Wijmo Control ( FlexGrid in your case) whenever the underlying data changes.
Here is sample code:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/wijmo.css" />
<link rel="stylesheet" type="text/css" href="css/app.css"/>
<!-- Angular 2 --/>
<script src="scripts/angular2.dev.js"/></script/>
<script src="scripts/wijmo.js" type="text/javascript"/></script/>
<script src="scripts/wijmo.input.js" type="text/javascript"/></script/>
<script src="scripts/wijmo.grid.js" type="text/javascript"/></script/>
<script src="scripts/wijmo.angular2.js" type="text/javascript"/></script/>
<!-- Load the root application module -->
<script>
System.import('./src/app');
</script>
</head>
<body>
<!-- Add root application component -->
<app-cmp>
<wj-flex-grid [itemsSource]="data">
</wj-flex-grid>
</app-cmp>
</body>
</html>
import { Injectable } from '@angular/core';
// Common data service
@Injectable()
export class DataSvc {
// data used to generate random items
getData(count: number): wijmo.collections.ObservableArray {
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
data = new wijmo.collections.ObservableArray();
for (var i = 0; i < count; i++) {
data.push({
id: i,
country: countries[i % countries.length],
date: new Date(2014, i % 12, i % 28),
amount: Math.random() * 10000,
active: i % 4 == 0
});
}
return data;
}
---------------------Component-------------------
// Angular
import { Component, EventEmitter, Input, Inject, enableProdMode, NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { BrowserModule } from '@angular/platform-browser';
import { WjGridModule } from 'wijmo/wijmo.angular2.grid';
import { WjInputModule } from 'wijmo/wijmo.angular2.input';
import { TabsModule } from './components/AppTab';
import { DataSvc } from './services/DataSvc';
// The Explorer application root component.
@Component({
selector: 'app-cmp'
})
export class AppCmp {
// generate some random data
protected dataSvc: DataSvc;
data: wijmo.collections.CollectionView;
constructor(@Inject(DataSvc) dataSvc: DataSvc) {
this.dataSvc = dataSvc;
this.data = new wijmo.collections.CollectionView(this.dataSvc.getData(100));
}
}
@NgModule({
imports: [WjInputModule, WjGridModule, BrowserModule, FormsModule, TabsModule],
declarations: [AppCmp],
providers: [DataSvc],
bootstrap: [AppCmp]
})
export class AppModule {
}
enableProdMode();
// Bootstrap application with hash style navigation and global services.
platformBrowserDynamic().bootstrapModule(AppModule);
You will need to push the data to the ObservableArray from your Service Implementation. You can use SignalR for this purpose. SignalR can be used to push data to your SPA/client app. There are some great articles on the same. You can read some of there from here and here
Thanks,
Abhishek