Angualarjs智能表搜索特定列

时间:2015-09-19 07:00:28

标签: angularjs smart-table

我已使用此文档smart table

<form>
    <label for="predicate">selected predicate:</label>
    <select class="form-control" id="predicate" ng-model="selectedPredicate" ng-options="predicate for predicate in predicates"></select>
</form>
<table st-table="rowCollection" class="table table-striped">
    <thead>
    <tr>
        <th st-sort="firstName">first name</th>
        <th st-sort="lastName">last name</th>
        <th st-sort="birthDate">birth date</th>
        <th st-sort="balance">balance</th>
        <th>email</th>
    </tr>
    <tr>
        <th>
            <input st-search="{{firstName}},{{lastName}}" placeholder="search for firstname" class="input-sm form-control" type="search"/>
        </th>
        <th colspan="3">
            <input st-search placeholder="global search" class="input-sm form-control" type="search"/>
        </th>
        <th>
            <input st-search="{{selectedPredicate}}" placeholder="bound predicate" class="input-sm form-control" type="search"/>
        </th>
    </tr>
    </thead>
    <tbody>
    <tr ng-repeat="row in rowCollection">
        <td>{{row.firstName | uppercase}}</td>
        <td>{{row.lastName}}</td>
        <td>{{row.birthDate | date}}</td>
        <td>{{row.balance | currency}}</td>
        <td><a ng-href="mailto:{{row.email}}">email</a></td>
    </tr>
    </tbody>
</table>

我使用st-search搜索特定列。它工作正常,但两列不工作。你能帮助我吗?我只需要搜索两列

2 个答案:

答案 0 :(得分:0)

显然没有办法直接使用内置的智能表来实现这一点。

您可以使用此处建议的指令: AngularJS smart-table search within multiple columns

答案 1 :(得分:0)

对于其他有相同问题的人,我还有另一个想法: 如果您的资料rowCollection不太大, 在页面init()中的javascript中执行以下操作:

self.rowCollection.forEach(function (element) {

  element.NameForFilter = element.firstName+ ' ' + element.lastName;  
});

,然后在第th个输入中:

st-search=NameForFilter