ngx-datatable 切换组不起作用

问题描述 投票:0回答:1

我正在使用

"@swimlane/ngx-datatable": "^17.0.0"
,我希望能够对行进行分组并切换它们。

我也想“正常”使用表格,这意味着我需要在分组和未分组(正常)之间切换。

这是带有道具的选择

groupBy

    <mat-form-field style="margin-left: 15px">
      <mat-select placeholder="Gruppieren nach..." [(value)]="groupBy">
        <mat-option [value]="null" (click)="table.groupedRows = null; loadRows()">Nicht gruppieren</mat-option>
        <mat-option *ngFor="let column of columns" [value]="column.prop" (click)="loadRows()">
          {{ column.name }}
        </mat-option>
      </mat-select>
    </mat-form-field>

这是组标题:

 <ngx-datatable-group-header *ngIf="groupBy" [rowHeight]="50" >
      <ng-template let-group="group" let-expanded="expanded" ngx-datatable-group-header-template>
        <div (click)="toggleExpandGroup(group)" >
          <b [class.datatable-icon-right]="!expanded" [class.datatable-icon-down]="expanded">
            {{ group.key + ': '+ group.value?.length }}
          </b>
       </div>
     </ng-template>
 </ngx-datatable-group-header>

*ngIf="groupBy"
从 null 更改时,组标题中的
toggleExpandGroup(group)
似乎会破坏
groupBy
|未定义到特定列。它不能再切换了。如果我删除它它就会起作用。但总是在“正常”视图中显示组标题。这是矛盾的。

我不明白为什么它会这样。是否有其他方法可以从分组切换到正常并返回?如果您需要更多代码,请告诉我。

感谢您提前提供的帮助。

angular ngx-datatable
1个回答
0
投票

这个问题你找到解决方案了吗?

© www.soinside.com 2019 - 2024. All rights reserved.