如何设置角度智能表的默认排序顺序

How to set default sort order on angular smart table?

本文关键字:智能 默认 顺序 排序 何设置 设置      更新时间:2023-09-26

我有一个Angularjs智能表,它为每一列(即哪个方向)设置了排序定义。

我想确保的是,每次加载页面时,都会保留原始的排序方向,最好是使用变量进行控制。我注意到,在我所做的一些分页代码中,当您选择第2页时,排序顺序有时会发生变化,因此您获得的第二页与第1页无关。

如何保持对排序的列和方向的控制并保持这种状态?

<table st-table="displayedCollection" st-pipe="getModelRuns" st-sort="EXECUTIONPOOL" st-sort-default="reverse" st-safe-src="rowCollection" class="table table-condensed" ng-show="displayedCollection.length > 0">
  <thead>
    <tr>
      <th st-sort="NAME" st-skip-natural="true"><i ng-class="getSortIcon('JobName')"></i> <a data-ng-href="#" style="white-space: nowrap">Job Name</a></th>
      <th st-sort="CLOUDJOBNAME" st-skip-natural="true"><i ng-class="getSortIcon('CloudJobName')"></i> <a data-ng-href="#" style="white-space: nowrap">Cloud Job Name</a></th>
      <th st-sort="MODELVERSION" st-skip-natural="true"><i ng-class="getSortIcon('ModelVersion')"></i> <a href="#">Model Version</a></th>
      <th st-sort="RUNSTATUS" st-skip-natural="true"><i ng-class="getSortIcon('Status')"></i> <a href="#">Status</a></th>
      <th st-sort="REQUESTEDAT" st-skip-natural="true" st-sort-default="reverse"><i ng-class="getSortIcon('Requested')"></i> <a href="#">Requested At</a></th>
      <th st-sort="STARTEDAT" st-skip-natural="true" st-sort-default="reverse"><i ng-class="getSortIcon('Started')"></i> <a href="#">Started At</a></th>
      <th st-sort="FINISHEDAT" st-skip-natural="true" st-sort-default="reverse"><i ng-class="getSortIcon('Finished')"></i> <a href="#">Finished At</a></th>
      <th st-sort="REQUESTEDBY" st-skip-natural="true"><i ng-class="getSortIcon('RequestedBy')"></i> <a href="#">Requested By</a></th>
      <th st-sort="EXECUTIONPOOL" st-skip-natural="true"><i ng-class="getSortIcon('ExecutionPool')"></i> <a href="#">Executed on Pool</a></th>
      <th />
    </tr>
  </thead>
</table>

我想您在表中要求默认升序,您可以像一样设置

st排序默认值="true"

但你设置了相反的顺序,所以对你来说可能是相反的。