我想要一个输入默认值来启动我的输入功能

时间:2019-02-07 15:09:50

标签: javascript html angular events dom-events

我有一个表,其中包含在组件中定义的表。列表上有不同的输入,我想将其中一些输入作为默认值:

<p-table #dt
  [value]="ACTIVITES"
  [columns]="columns"
  [paginator]="true"
  [rows]="8"
  [scrollable]="true"
  [resizableColumns]="true"
  [responsive]="true"
  selectionMode="single"
  [(selection)]="selectedOM"
  (onRowSelect)="onClickItem()"
  class="top"
  >
  <ng-template pTemplate="colgroup" let-columns>
      <colgroup>
          <col *ngFor="let col of columns" [style.width]="col.width">
      </colgroup>
  </ng-template>
  <ng-template pTemplate="header">
      <tr>
          <th *ngFor="let col of columns" [pSortableColumn]="col.field" pResizableColumn>
              {{col.header}}
              <p-sortIcon [field]="col.field"></p-sortIcon>
          </th>
      </tr>
      <tr>
          <th *ngFor="let col of columns" [ngSwitch]="col.field">
        <p-dropdown *ngSwitchCase="'etat'" [options]="etats" appendTo="body" class="prime-table-filter-input" (onChange)="dt.filter($event.value, col.field, 'equals')"></p-dropdown>
        <input *ngSwitchDefault pInputText type="text" value={{col.defaultValue}} class="prime-table-filter-input" (input)="dt.filter($event.target.value, col.field, 'contains')">
      </th>
      </tr>
  </ng-template>
  <ng-template pTemplate="body" let-item>
      <tr [pSelectableRow]="item">
          <td> blablabla</td>
      </tr>
  </ng-template>
</p-table>

在组件中,我的列定义如下:

this.columns = [
        { field: 'annee', header: 'Année', width: '5%', defaultValue: new Date().getFullYear()},
        { field: 'mois', header: 'Mois', width: '5%', defaultValue: new Date().getMonth() + 1},
        { field: 'user.lastName', header: 'Nom'},
        { field: 'user.firstName', header: 'Prénom'},
        { field: 'missions[0].client.raisonSociale', header: 'Client'},
        { field: 'missions[0].reference', header: 'Mission'},
        { field: 'missions[0].dateDebutPrev', header: 'Date début'},
        { field: 'missions[0].dateFinPrev', header: 'Date fin'},
        { field: 'etat', header: 'Etat'}
      ];

现在,默认值显示在输入值上,但是我希望用这些值过滤我的表。 我不知道是否可以使用这些默认值(输入)在模板中定义的功能。

您能帮我找到解决方法吗?

0 个答案:

没有答案
相关问题