Как предотвратить пагинацию или загрузку в следующий раз, когда данные текущей страницы не сохраняются с помощью PrimeNg Ptable? - PullRequest
0 голосов
/ 24 октября 2019

Вот мой HTML-код P-таблицы

<p-table #pcd [columns]="pcdTableColumns" [value]="pcdDictionaries" [lazy]="true" (onLazyLoad)="loadPcdDictionariesLazy($event)"
            [paginator]="true" [rows]="noOfRowsPcd" [ngClass]="{'ui-state-disabled': disablePaginator}" [multiSortMeta]="multiSortMeta" sortMode="multiple" [totalRecords]="pcdTotalRecords"
            [loading]="pcdLoading" [rowsPerPageOptions]="[25,50,75,100]"> <ng-template pTemplate="header" let-columns>
        <tr>
            <th *ngFor="let col of columns" [pSortableColumn]="col.field">{{col.header | translate}} <span> <p-sortIcon
                        [field]="col.field"></p-sortIcon>
            </span>
            </th>
            <th [pSortableColumn]="'userControl'">{{'Under Control' | translate}} <span> <p-sortIcon [field]="'userControl'"></p-sortIcon>
            </span>
            </th>
        </tr>
        </ng-template> <ng-template pTemplate="body" let-rowData let-columns="columns">
        <tr>
            <td *ngFor="let col of columns">
                <div *ngIf="col.field === 'bcvUsage'">
                    <div *ngIf="rowData[col.field] === 1;else not_bcv_usage">Y</div>
                    <ng-template #not_bcv_usage>N</ng-template>
                </div>
                <div *ngIf="col.field !== 'bcvUsage'" style="word-wrap: break-word;">{{rowData[col.field]}}</div>

            </td>
            <td><p-inputSwitch [(ngModel)]="rowData.checked" (onChange)="onPcdDictionaryChange(rowData)"> </p-inputSwitch></td>
        </tr>
        </ng-template> </p-table>

Вот мой угловой код, в котором я пытаюсь обнаружить несохраненные данные из P-таблицы

  loadPcdDictionariesLazy(event: LazyLoadEvent) {
    if(this.IsSaveData){
      console.log("load table data");
      this.first = event.first;
      this.noOfRowsPcd = event.rows;
      if (event.multiSortMeta) {
        this.pcdSortField = event.multiSortMeta[0].field;
        this.pcdSortOrder = event.multiSortMeta[0].order;
      }
      this.displayPcdDictionary(false, event.first);
    } else {
      console.log("Show popup");
      this.confirmationService.confirm({
        message: 'Do you want to go without saving changes',
        header: 'Confirmation',
        icon: 'pi pi-exclamation-triangle',
        accept: () => {
          this.IsUserControl = false;
          this.IsSaveData = true;
          this.first = event.first;
          this.noOfRowsPcd = event.rows;
          if (event.multiSortMeta) {
            this.pcdSortField = event.multiSortMeta[0].field;
            this.pcdSortOrder = event.multiSortMeta[0].order;
          }
          this.displayPcdDictionary(false, event.first);
        },
        reject: () => {
          let pageIndex = event.first/event.rows + 1;
          this.IsUserControl = true;
          this.IsSaveData = false;
        }
      });
    }

с помощью PrimeNg P-Таблица Как остановить пагинацию или избежать загрузки данных следующей страницы, пока данные не сохраняются на текущей странице? если вы меняете страницу, то без сохранения нужных мне данных отображается всплывающее окно.

...