Cannot set property 'offset' of undefined when filtering
See original GitHub issueI’m submitting a … (check one with “x”)
[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter
Current behavior When I type in the filter box, it gives the error: “Cannot set property ‘offset’ of undefined”
Expected behavior It is supposed to filter the rows.
Reproduction of the problem http://plnkr.co/edit/BP5Zw2
[import { Component, ViewChild } from '@angular/core';
import { DatatableComponent } from '../../../node_modules/@swimlane/ngx-datatable/src/components/datatable.component';
@Component({
selector: 'app-school-list',
template: `
<input type='text'
placeholder='Type to filter the name column...'
(keyup)='updateFilter($event)' />
<ngx-datatable
#table
[columns]="columns"
[footerHeight]="50"
[limit]="5"
[rows]='rows'>
</ngx-datatable>
`
})
export class SchoolListComponent {
temp = [];
columns = [
{ prop: 'name' },
{ name: 'Gender' },
{ name: 'Company' }
];
rows = [
{ name: 'Austin', gender: 'Male', company: 'Swimlane' },
{ name: 'Bobby', gender: 'Male', company: 'KFC' },
{ name: 'Christina', gender: 'Female', company: 'Burger King' },
{ name: 'Dustin', gender: 'Male', company: 'Swimlane' },
{ name: 'Ellie', gender: 'Female', company: 'KFC' },
{ name: 'Flower', gender: 'Female', company: 'Burger King' },
{ name: 'Gordon', gender: 'Male', company: 'Swimlane' },
{ name: 'Houston', gender: 'Male', company: 'KFC' },
{ name: 'Ian', gender: 'Male', company: 'Burger King' }
];
@ViewChild(DatatableComponent) table: DatatableComponent;
constructor() {
this.temp = this.rows;
}
updateFilter(event) {
const val = event.target.value.toLowerCase();
const temp = this.temp.filter(function (d) {
return d.name.toLowerCase().indexOf(val) !== -1 || !val;
});
this.rows = temp;
this.table.offset = 0;
}
}
What is the motivation / use case for changing the behavior? No errors
Please tell us about your environment:
-
Table version: 0.8.x 9.1.0
-
Angular version: 2.0.x 4.0.2
-
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] Chrome v57
-
Language: [all | TypeScript X.X | ES6/7 | ES5] Typescript 2.1.5
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
ngx datatables 'Cannot set property 'offset' of undefined' when ...
I am trying to use ngx-datatables in my angular 2 app. I tried following the example: https://github.com/swimlane/ngx-datatable/blob/master/demo ...
Read more >ngx datatables 'Cannot set property 'offset' of undefined' when ...
Coding example for the question ngx datatables 'Cannot set property 'offset' of undefined' when filtering-angular.js.
Read more >How to avoid undefined offset error in PHP ? - GeeksforGeeks
isset() function : This function checks whether the variable is set and is not equal to null. It also checks if array or...
Read more >Uncaught TypeError: Cannot read property 'offset' of undefined
And here is the Error ( It crashes at the first console log) tsc-emit.js:37 Uncaught TypeError: Cannot read property 'offset' of undefined
Read more >HTML DOM Style filter Property - W3Schools
Applies a blur effect to the image. A larger value will create more blur. If no value is specified, 0 is used. brightness(%),...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
First off, I think you need to import like this:
import { DatatableComponent } from '@swimlane/ngx-datatable/src/components/datatable.component';
Secondly, I think you need to write the View Child like this:
@ViewChild('table') table: DatatableComponent;
@amcdnl The example demo (https://github.com/swimlane/ngx-datatable/blob/master/demo/basic/filter.component.ts) is making reference to ‘#table’ from the template. So, I think the above syntax works.
It worked for me.
@NivethaMuthukumar Its clear from the error that your
webpack.config
is not loading this ngx-datatables module and therefore, typescript compilation is failing.