TypeError: Cannot read property 'length' of undefined ( allRowsSelected )
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
since version 11.1.x I have the following error in console
DatatableComponent.html:5 ERROR TypeError: Cannot read property 'length' of undefined
at DatatableComponent.get [as allRowsSelected] (index.js:4867)
at Object.eval [as updateDirectives] (DatatableComponent.html:18)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:14339)
at checkAndUpdateView (core.js:13508)
at callViewAction (core.js:13858)
at execEmbeddedViewsAction (core.js:13816)
at checkAndUpdateView (core.js:13509)
at callViewAction (core.js:13858)
at execComponentViewsAction (core.js:13790)
at checkAndUpdateView (core.js:13514)
It seems to be a new feature, so maybe some issues there ? I haven’t changed my code since 11.0.4 which is as follow :
<ngx-datatable
class="material fullscreen"
[columnMode]="'force'"
[rowClass]="getRowClass"
[headerHeight]="50"
[footerHeight]="50"
[rowHeight]="50"
[externalPaging]="true"
[externalSorting]="true"
[loadingIndicator]="loading"
[limit]="pageSize"
[offset]="pageOffset"
[count]="totalCount"
[rows]="items"
[columns]="columns"
[messages]="{emptyMessage: 'DataTable.EmptyMessage' | translate, totalMessage: 'DataTable.Total' | translate, selectedMessage: 'DataTable.SelectedMessage' | translate}"
(page)="onPageChanged($event)"
(sort)="onSortChanged($event)"
(scroll)="onScroll($event.offsetY)"
(reorder)="onColumnsReordered($event)">
<!-- Header template -->
<ng-template #headerTemplate let-column="column" let-sort="sortFn">
<span class="datatable-header-cell-wrapper"><span class="datatable-header-cell-label draggable text-truncate" (click)="sort()">{{ column.name | translate }}</span></span>
</ng-template>
<!-- Cell template -->
<ng-template #cellTemplate let-column="column" let-value="value">
<div [innerHTML]="getCellHtml(value, column)"></div>
</ng-template>
<!-- Actions template -->
<ng-template #actionTemplate let-row="row" let-value="value">
<button mat-icon-button (click)="onDeleteClick(value)" [attr.disabled]="!canDelete" color="warn" matTooltip="{{'CRM.Delete' | translate}}" [matTooltipPosition]="'below'">
<i class="material-icons">delete</i>
</button>
<button mat-icon-button (click)="onEditClick(value)" [attr.disabled]="!canEdit" matTooltip="{{'CRM.Edit' | translate}}" [matTooltipPosition]="'below'">
<i class="material-icons">create</i>
</button>
</ng-template>
</ngx-datatable>
Please tell us about your environment:
win10 pro, vscode, npm, node
- Table version: 0.8.x
11.1.2
- Angular version: 2.0.x
5.0.2
- Browser:
chrome 62.0.3202.94
- Language: [all | TypeScript X.X | ES6/7 | ES5] typescript 2.6.1
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:39 (4 by maintainers)
Top Results From Across the Web
ngx-datatable "Cannot read property 'length' of null" after ...
1.5 I am getting an error. ERROR TypeError: Cannot read property 'length' of null at DatatableComponent.
Read more >Cannot Read Property Length of Undefined in JavaScript
The JavaScript TypeError: Cannot read property 'length' of undefined occurs when the length property is read on an undefined variable.
Read more >Datatables - Cannot Read Property 'Length' Of Undefined
Hi I am getting below error Uncaught TypeError: Cannot read property 'length' of undefined at xb (jquery.dataTables.min.js:39) at jquery. Hi I am getting...
Read more >Cannot read property 'length' of undefined at Editor._sspSort
Link to test case: http://kiwiplankdc.com:8080/ Debugger code (debug.datatables.net): Added Error messages shown: TypeError:
Read more >T196141 Cannot read property 'length' of undefined
[2018-06-01T08:43:24.558Z] FATAL: tilerator/14 on maps-test2004: (levelPath=fatal/service-runner/unhandled) TypeError: Cannot read property 'length' of ...
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
Me too - Version 11.1.4 receiving the same error. The problem in my case is because an uninitialized object is assigned to the [row] property or it is not an array type.
In my html: <ngx-datatable class = “material” [rows] = “customers” [loadingIndicator] = “loadingIndicator”> …
In my component.ts:
public customers: any; // <- here’s the problem …
The solution, assign an object of type initialized array:
In my component.ts:
public customers: Array
<any>
= new Array<any>
(); // <- solution …The best solution is to initialize the array of the customer type in my case public customers: Array
<customer>
= new Array<customer>
(); // <- best solutionI hope you seriva for help, I have solved the problem.
Try 11.1.7 plz