0

I am trying to show data as it comes in from the API.

What I am doing is:

var qstring = ['http://localhost:57398/api/values/passdata?query=select * from t1 order by id offset 0 rows fetch next 1000 rows only', 'http://localhost:57398/api/values/passdata?query=select * from t1 order by id offset 1000 rows fetch next 1000 rows only', 'http://localhost:57398/api/values/passdata?query=select * from t1 order by id offset 2000 rows fetch next 1000 rows only', 'http://localhost:57398/api/values/passdata?query=select * from t1 order by id offset 3000 rows fetch next 1000 rows only'];

return Observable.from(qstring).mergeMap(d => this.http.get(d).map(res => res.json() as any));

to Bind

source: any;

 this.service.getDataFromServer().subscribe(data => {
            this.source = this.sdata;
        }, Error => {
            console.log(Error);
        });

Template

 <ng2-smart-table [settings]="settings" [source]="source" ></ng2-smart-table>

But it only shows the last one. How can I make sure that data is appended and not overriden?

Vega
  • 27,856
  • 27
  • 95
  • 103
  • Updated bindings – nitin jain Aug 18 '17 at 02:19
  • What console.log(qstring) does give you. I think your problem resides there. – Vega Aug 18 '17 at 07:04
  • There's no error as it overrides, so i used an array to bind it to grid which seems like a hack newItems: any[] = []; for (var element in data) { let marker = data[element]; this.newItems.push( { id: marker.id }) } this.source = this.newItems; – nitin jain Aug 21 '17 at 02:57
  • So source data didn't have the correct format, i.e didn't have {id:...} but it had the whole query result without id key? It's not a hack :) – Vega Aug 21 '17 at 05:24

0 Answers0