使用智能表进行二级排序?

时间:2015-12-28 09:19:23

标签: angularjs smart-table

我有一个使用智能表的分页表。我想首先使用状态和代码进行排序。我不能使用AngularJS中的orderBy,因为它会对每个页面的元素进行排序,而不是全部。并且只有一列的智能表订单的st-sort-default。

<table st-table="lista.displayedPublications" st-safe-src="lista.publications">
      <thead>
          <tr>
               <th st-sort="publication.status" >STATO</th>
               <th st-sort="publication.communicationCode">TREAT CD</th>                      
               <th> ... </th>
          </tr>
      </thead>
      <tbody>
          <tr ng-repeat="publication in lista.displayedPublications">
               <td>{{publication.status}}</td>
               <td>{{publication.communicationCode}}</td>
               <td>...</td>                 
           </tr>
       </tbody>
             <tfoot>
                <tr>
                    <td>
                        <div st-template="ListaTreatement/pagination.html" st-pagination="" st-items-by-page="10"></div>
                    </td>
                 </tr>
              </tfoot>
  </table>

在控制器中:

public publications: PublicationExtended[];
public displayedPublications = [].concat(this.publications);
constructor(...){
     new Api($http).getList(me.comunicationType, me.comunicationStatus).then(
        function(response : angular.IHttpPromiseCallbackArg<PublicationExtended[]>) {
            me.publications = response.data;
        }
}

1 个答案:

答案 0 :(得分:2)

在控制器中使用$filter("orderBy")($scope.lista.displayedPublications, ["+status", "+code"]);对数据进行排序,然后再将其提供给您的表格。 +-可用于设置降序或升序排序。

相关问题