Jhipster table with search fields by columns

房东的猫 提交于 2020-05-16 20:42:22

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!