ngx-datatables gives "rxjs_1.fromEvent is not a function" error while sorting
Asked Answered
N

1

7

I'm just following the demo to show a simple datatable. Here is my code:

columns = [
    {name: 'ID', prop: 'id'},
    {name: 'Street Address', prop: 'address.street'},
    {name: 'Suburb', prop: 'address.suburb'},
    {name: 'State', prop: 'address.state'},
    {name: 'Manager Name', prop: 'manager.name'},
    {name: 'Manager Company', prop: 'manager.company'},
  ];
<ngx-datatable #table
  class = 'material striped'
  [columns] = "columns"
  [rows] = "rows | async"
  [footerHeight] = "25" >
</ngx-datatable>

Sorting does work but, I'm also getting this error when I click on a column to sort the records:

enter image description here

I get rows as Observable from Firestore.

Northeast answered 12/5, 2018 at 3:54 Comment(14)
Show your RxJS imports.Cattleman
import {Observable} from 'rxjs/Observable'; Just thisNortheast
Where did you import fromEvent?!Cattleman
I never do it. I'm just using angularfire2 to get data and store its snapshot in an observable, which i then pass to rows.Northeast
The Error is in the DataTableHeaderComponent.htmlNortheast
ngOnInit() { this.propertyService .valueChnages() .subscribe(properties => this.rows = properties); } Just like this.Northeast
Are you using fromEvent in your LongPressDirective?Snowman
I don't have a LongPressDirective. i just copy and pasted the most basic example to create a simple datatable.Northeast
Which version ngx-datatable are you using? I suspect it's 12.0.0 which requires rxjs6Blok
Yes: "@swimlane/ngx-datatable": "^12.0.0"Northeast
Should I use rxjs-compat? Or downgrade to an earlier version?Northeast
Try rxjs- compat. I would upgrade angular to version 6Blok
I'm in a middle of a project, I'm not confident that upgrading would not break by code in terms of comparability with other libraries that I'm using such as AngularFire2.Northeast
What previous version would you recommend that would work fine with angular 5?Northeast
D
17

The version of ngx-datatable and rxjs that you're using are incompatible.

If you're using ngx-datatable@^12.0.0, then you need rxjs@^6.0.0.

If you can't upgrade rxjs (because, for example, you still need to use v5 of Angular), then you can use [email protected] which works with rxjs@^5.0.0.

Dished answered 21/5, 2018 at 2:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.