如何禁用Angular Datatables中数据的初始排序?

Dev*_*ikh 1 javascript datatables angularjs angular-datatables

我正在使用角度数据表,并且只有一列。

当我绑定它时,数据按升序排列,而我想按接收到的顺序显示它。

有人可以帮忙吗?

控制器:

        var vm = this;
        vm.dtOptions = DTOptionsBuilder.newOptions()
        .withButtons([
            'print',
            'pdfHtml5',

        ]);
        vm.dtColumnDefs = [
            DTColumnDefBuilder.newColumnDef(0).notSortable()
        ];
Run Code Online (Sandbox Code Playgroud)

HTML:

  <div ng-controller="formViewController as frmView">
    <table datatable="ng" dt-options="frmView.dtOptions" dt-column-defs="frmView.dtColumnDefs" class="row-border hover">
        <thead>
            <tr>
                <td>
                    {{Title}}
                </td>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="plugin in newArray track by $index">
                <td>
                    //Content
                </td>
            </tr>
        </tbody>
    </table>
</div>
Run Code Online (Sandbox Code Playgroud)

dav*_*rad 5

看一下order,原名aaSorting。加

.withOption('order', [])
Run Code Online (Sandbox Code Playgroud)

给你dtOptions。order的默认值是[[0, 'asc']],将其设置为[]可以防止dataTables在初始化后对第一列进行初始排序。