如何将我想要排序的列传递给Angularjs中的智能表

时间:2015-02-09 16:53:28

标签: angularjs smart-table

我正在使用智能表来显示在代码中构建为对象数组的通用数据列表。 我希望能够在任何列上应用排序,如何传递列名以排序到getter?目前我只能对硬编码列进行排序。

                                          {{item.displayName}}                                                                                                            

                                          {{item.displayName}}                                                                                                            

1 个答案:

答案 0 :(得分:0)

你需要做的就是将st-sort与表体中的相应名称相匹配,参见下面的例子。单击“年龄”将仅对“年龄”列进行排序。

<table st-table="example" class="table table-striped">
  <thead>
    <tr>
      <th></th>
      <th st-sort="name">Name</th>
      <th st-sort="age">Age</th>
    </tr>
  </thead>
  <tbody>
    <tr ng-repeat="example in examples">
      <td cs-select="row"></td>
      <td>{{example.name}}</td>
      <td>{{example.age}}</td>
    </tr>
  </tbody>
</table>