1

ngx-datatable でドロップダウンを使用すると問題が発生します。ユーザーがドロップダウンからアイテムを選択すると、他のすべてのドロップダウンがその選択したアイテムに設定されます。使ってみました

let-rowIndex="rowIndex"</p>

運がない。

これが私がこれまでに持っているものです。

<ngx-datatable
  class="material"
  [rows]='bankingStatements'
  [columnMode]="'force'"
  [headerHeight]="50"
  [footerHeight]="50"
  [rowHeight]="'auto'"
  [limit]="10">
  <ngx-datatable-column [width]="50" name="Paid by..."
                        [sortable]="true" [draggable]="false">
    <ng-template let-row="row" let-rowIndex="rowIndex" ngx-datatable-cell-template>

      <md-select class="paid-in-select" [(ngModel)]="selectedItem" (change)="checkIfCustomerExists(rowIndex)" name="{{rowIndex}}" id="customers-{{rowIndex}}">
        <md-option *ngFor="let cust of paidInSelect" [value]="cust">

          <div *ngIf="cust.customers?.customer_name;  else elseOther">
            {{cust.customers?.customer_name}}
          </div>

          <ng-template #elseOther>
            {{cust?.customers}}
          </ng-template>

        </md-option>
      </md-select>

    </ng-template>
  </ngx-datatable-column>
</ngx-datatable>

どんな助けでも大歓迎です。

4

1 に答える 1

1

これは、すべての行の選択が同じに設定されているため[(ngModel)]です。各行を異なる ngModel オブジェクトにバインドする必要があります。例: 配列:

[(ngModel)]="selectedItem[rowIndex]"
于 2017-09-21T09:51:19.140 に答える