本文介绍了按列搜索字段的Jhipster表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中使用jhipster.我有一个向其中添加了分页和排序功能的表,但是我也想在列中添加一个搜索字段,这可能吗?就像这样 http://ng-table.com/

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/

我的HTML是:

<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>

谢谢.

推荐答案

我设法使用输入和angular的'purefilter'属性来做到这一点.就是这样:

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')>
.......

在pureFilter中,我们指示'pureFilter:nameOfFilter:attributeOfEntity'

In pureFilter we indicate 'pureFilter:nameOfFilter:attributeOfEntity'

这篇关于按列搜索字段的Jhipster表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 08:49