私は、ユーザーがプレビューのdivに表示されている別のページからレコードを選択できるようにする(1)スマート・テーブルを使用しています。スマートテーブルを使用してページを変更した後も選択を維持する方法は?
現在の問題は、私は最初のページから一部のレコードを選択すると、秒に移動していることであり、第1に戻って移動し、最初のページでの選択は、前の選択を反映していません。
operatorSelection(2)というマップに保存されている場合、現在の選択はonChangedSourceイベント(3)の後で行を再度選択することでしたが、multipleSelectRow()を呼び出してもgetSelectedRows予想される行
ページ変更後の選択を維持するための他の方法はありますか?またはコードから行を選択する他の方法?
(1)成分を返すHTML
<div class="col-lg-6"> <ng2-smart-table #grid [settings]="settings" [source]="source" (userRowSelect)="onUserRowSelect($event)"> </ng2-smart-table> </div>
行選択のために(2)成分のコード
onUserRowSelect(event) {
console.log('on UserRowSelect', event, this.operatorSelection);
if (event.isSelected) {
this.operatorSelection.set(event.data.code, event.data);
} else {
this.operatorSelection.delete(event.data.code);
}
this.updatePreview();
}
(3)もの:ここ
はコードの断片でありますページを変更した後で選択を更新しようとしました
ngAfterViewInit(): void {
this.table.grid.source.onChangedSource.subscribe(() => {
this.operatorSelection.forEach((row) => {
this.table.grid.source.data.forEach((element) => {
if (element.code == row.code) {
console.log('--- reselect ', row.code);
this.table.grid.multipleSelectRow(row);
console.log('*** selected ', this.table.grid.getSelectedRows());
}
});
});
});
}