如何将默认排序设置为 jh-table?

How to set a default sorting to a jh-table?

我有一个 jh-table 和一个按每个字段排序的工作 header,但我希望在加载页面时默认按特定字段排序。

我试图在 tbody 的 ng-repeat 中设置 orderBy,但我认为这会导致与 jh-sort 发生冲突并且排序按钮无法正常工作。

有没有办法在 thead 中定义默认排序?

这是我的主题:

<thead>
    <tr jh-sort="vm.predicate" ascending="vm.reverse" callback="vm.transition()">
        <th jh-sort-by="id"><span data-translate="global.field.id">ID</span> <span class="glyphicon glyphicon-sort"></span></th>
        <th jh-sort-by="name"><span data-translate="global.field.name">Nome</span> <span class="glyphicon glyphicon-sort"></span></th>
        <th jh-sort-by="date"><span data-translate="cccApp.certificateRequestBatch.creationDate">Data de cadastro</span> <span class="glyphicon glyphicon-sort"></span></th>
        <th jh-sort-by="status"><span data-translate="global.field.status">Situo</span> <span class="glyphicon glyphicon-sort"></span></th>
        <th></th>
    </tr>
</thead>

在您的 certificateRequestBatch 实体状态文件 (certificate-request-batch.state.js) 中,您可以通过 sort 键设置 sorting/pagination 的默认参数:

params: {
    page: {
        value: '1',
        squash: true
    },
    sort: {
        value: 'id,asc',
        squash: true
    },
    search: null
},

AngularJS can be seen here.

实体状态的完整示例