问题
im using jhipster in my application. I have a table to which I have added pagination and sorting, but I would also like to add a search field in a column, this would be possible? It would be something like this http://ng-table.com/
My HTML is:
<div class="table-responsive" *ngIf="entities">
<table class="table table-striped">
<thead>
<tr jhiSort [(predicate)]="predicate" [(ascending)]="reverse" [callback]="transition.bind(this)">
<th jhiSortBy="id"><span jhiTranslate="global.field.id">ID</span> <span class="fa fa-sort"></span></th>
<th jhiSortBy="nombre"><span jhiTranslate="app.entity.name">Name</span> <span class="fa fa-sort"></span></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let entity of entities ;trackBy: trackId">
<td><a [routerLink]="['../entity', entity.id ]">{{entity.id}}</a></td>
<td>{{entity.name}}</td>
</tr>
</tbody>
</table>
</div>
Thank you.
回答1:
I managed to do it using an input and the 'purefilter' attribute of angular. It was such that:
<input type="text" [(ngModel)]="filter" class="form-control">
<table>
......
<tr *ngFor="let entity of (entities | pureFilter:filter:'name')>
.......
In pureFilter we indicate 'pureFilter:nameOfFilter:attributeOfEntity'
来源:https://stackoverflow.com/questions/55239571/jhipster-table-with-search-fields-by-columns