Reputation: 611
I'm following this guide I found online Tutorial: Angular 2 Datatable with Sorting, Filtering and Resizable Columns - it seems like the simplest tutorial I could find that would ease me into the ag-grid library before I can dig deeper into it's documentation. I've copy pasted their code onto my project, the only difference is that I have a bunch other components and services for other things I've been experimenting but this shouldn't be a conflict.
The error I'm getting says
error TS2322: Type '{ [x: number]: undefined; rowData: { "name": string; "country": string; "city": string; "email": ...' is not assignable to type 'any[]'. Property 'length' is missing in type '{ [x: number]: undefined; rowData: { "name": string; "country": string; "city": string; "email": ...'.
I'm not sure what to make of it, here is the constructor. constructor(private _tableDataService: TableData, private _httpService:
HTTPTestService){
this.gridOptions = {
rowData: this.myRowData,
columnDefs: this.columnDefs,
enableColResize: true,
enableSorting: true,
enableFilter: true
}
}
I'll share the full component on my gist here Thank you. :-)
Upvotes: 0
Views: 1287
Reputation: 202276
Perhaps you could try this because of the error message "... is not assignable to type 'any[]' ...":
gridOptions: any = {}; // <------
constructor(private _tableDataService: TableData,
private _httpService: HTTPTestService) {
this.gridOptions = {
rowData: this.myRowData,
columnDefs: this.columnDefs,
enableColResize: true,
enableSorting: true,
enableFilter: true
}
}
You initialize the gridOptions
as an array and then you set it as an object...
Upvotes: 1