【问题标题】:Angualarjs smart table search particular columnsAngularjs智能表搜索特定列
【发布时间】:2019-09-22 16:23:29
【问题描述】:

我用过这个文档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 搜索特定列。它工作正常,但两列不工作。你能帮助我吗?我只需要搜索两列

【问题讨论】:

    标签: angularjs smart-table


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      对于遇到同样问题的其他人,我有另一个想法: 如果你的数据 rowCollection 不是太大, 在页面 init() 的 javascript 中执行以下操作:

      self.rowCollection.forEach(function (element) {
      
        element.NameForFilter = element.firstName+ ' ' + element.lastName;  
      });
      

      然后在th的输入中:

      st-search=NameForFilter
      

      【讨论】:

        猜你喜欢
        • 2015-05-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-12-25
        • 2021-03-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多