无法读取未定义的ngx-datatable的属性“索引”

时间:2019-07-30 15:10:22

标签: angular angular8 ngx-datatable

我使用ngx数据表版本:15.0.2和Angular版本:8.1.0,

我有此错误:

  

ngx-logger.js:852 2019-07-30T15:04:42.930Z错误[main.js:4696]   TypeError:无法读取DatatableComponent.get中未定义的属性“索引” [作为allRowsSelected](index.js:3263)   在Object.eval [作为updateDirectives](DatatableComponent.html:19)

这是此表的Angular 8.1.0和15.0.2版上的一个问题。对于该库的Angular 7和版本14来说,这不是问题。

这是我的代码:

 <ngx-datatable 
    *ngIf='!containerLoader && (containers | async)?.length!=0'
    class="bootstrap striped" 
    [rows]="containers|async" 
    [columnMode]="'force'" 
    [headerHeight]="50" 
    [footerHeight]="50" 
    [rowHeight]="'auto'" 
    [externalPaging]="true"
    [count]="page.totalElements"
    [offset]="page.pageNumber"
    [limit]="page.size"
    (page)='loadData($event)'
    [selectCheck]="true"
    [displayCheck]="displayCheck"
    [loadingIndicator]="loadingIndicator"
    >
        <ngx-datatable-column [width]="80" name="" prop="status">
            <ng-template let-row="row" let-value="value" ngx-datatable-cell-template>
                <div *ngIf="row.progress && row.progress <100; else status">
                    <span class=" progress-{{row.progress}} progress-circle " 
                        [attr.data-sectionvalue]="row.uuid">
                    </span>
                </div>
                <ng-template #status>
                    <span class="{{value |state:'badge'}}" 
                        [attr.data-sectionvalue]="row.uuid">
                    </span>
                </ng-template>
            </ng-template>
        </ngx-datatable-column>
        <ngx-datatable-column [width]="200" name="Name" prop="name">
            <ng-template let-row="row" let-value="value" ngx-datatable-cell-template>
                <span>{{value}}</span>
            </ng-template>
        </ngx-datatable-column>
        <ngx-datatable-column name="Memory" prop="package.memory_limit">
            <ng-template let-row="row" let-value="value" ngx-datatable-cell-template>
                <span>{{value |convert:2:true}}</span>
            </ng-template>
        </ngx-datatable-column>
        <ngx-datatable-column name="Disk" prop="package.disk_size">
            <ng-template let-row="row" let-value="value" ngx-datatable-cell-template>
                <span>{{value |convert:2:true }}</span>
            </ng-template>
        </ngx-datatable-column>
        <ngx-datatable-column name="Created at" prop="created_at">
            <ng-template let-row="row" let-value="value" ngx-datatable-cell-template>
                <span>{{value | date:"fullDate"}}</span>
            </ng-template>
        </ngx-datatable-column>
</ngx-datatable>

2 个答案:

答案 0 :(得分:2)

这可能与以下问题有关

https://github.com/swimlane/ngx-datatable/issues/1725

我设法通过设置

来显示表格
[selectAllRowsOnPage]="false"

答案 1 :(得分:1)

这是ngx-datatable的问题#1725,但是它是开放的,因此您有两种选择,要么等待下一个版本15.0.3,要么使用此临时解决方案

npm install git+https://github.com/zackarychapple/ngx-datatable.git - S