2

I am loading PrimeNg turbotable lazily. Everything is working properly. But I want to load the data with some default Filter value Say: I want to load data with User Id who is Logged. Dynamically I am setting the value of text filter or Dropdwon filter using [(ngModel)]. But I do not see any changes in Filter of TurboTable Event. Everthing is empty.

<p-table #tt [value]="data" [lazy]="true" (onLazyLoad)="loadDataLazily($event)"
    [paginator]="true"
        [rows]="10 [totalRecords]="totalRecords">
          <ng-template pTemplate="header">
              <tr>
                <th *ngFor="let col of cols" [ngSwitch]="col.field">
                  {{col.header}}
                </th>
              </tr>
            <tr>
           <th *ngFor="let col of cols" [ngSwitch]="col.field">
            <input *ngSwitchCase="'NAME'" pInputText style="width:100%;" type="text"
                (input)="tt.filter($event.target.value, 'NAME')">
             <p-dropdown *ngSwitchCase="'USERID'" [options]="ids" [style]="{'width':'100%'}"
                 [(ngModel)]="selectedUserId" (onChange)="tt.filter($event.value, 'USERID', 'equals')">
             </p-dropdown>
              </th>
             </tr>
            </ng-template>
...
</p-table>

I tried below but no luck instead of $event.value in tried ngModel value:

    <p-dropdown *ngSwitchCase="'USERID'" [options]="ids" 
[style]="{'width':'100%'}"
                     [(ngModel)]="selectedUserId" (onChange)="tt.filter(selectedUserId, 'USERID', 'equals')">
                 </p-dropdown>
DirtyMind
  • 2,353
  • 2
  • 22
  • 43

0 Answers0