relair / odata-data-source

Data source for material table and angular cdk table that can work with OData version 4 API.
MIT License
12 stars 6 forks source link

access underlying data #2

Closed christophedemey closed 5 years ago

christophedemey commented 5 years ago

Hi @relair

For delete functionality on this table i would like to slice the table data array so the row is immediately removed and the user does not have to wait for the http call to end. They also cant delete the row quickly 2x then also.

But i cannot find how i would expose the underlying data of the table. Any ideas ?

Thanks!

christophedemey commented 5 years ago

@relair found it :) exposing data as a property like so

data: Array<any>;

init in constructor

this.data = new Array<any>();

then in function createObservablePipe at the tap pipe i added.

this.data = result['value'];

Then to refresh locally i did

  refreshLocal(): void {
    this.dataSubject.next(this.data);
  }

To refresh from service i did

  refreshServer(): void {
    this.paginator._changePageSize(this.paginator.pageSize);
  }

I'll put it in a pull request for you :)