如何禁用Angular Datatables中数据的初始排序? [英] How to disable initial Ordering of data in Angular Datatables?

查看:73
本文介绍了如何禁用Angular Datatables中数据的初始排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using angular datatables and I have only one column.

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

When I bind it, the data comes in an ascneding order, while I want to display it in the order I recived it.

有人可以帮忙吗?

控制器:

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

        ]);
        vm.dtColumnDefs = [
            DTColumnDefBuilder.newColumnDef(0).notSortable()
        ];

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>

推荐答案

查看 order ,以前称为aaSorting.添加

Look at order, formerly known as aaSorting. Add

.withOption('order', [])

到您的dtOptions. order的默认值为[[0, 'asc']],将其设置为[]将防止dataTables在初始化后对第一列进行初始排序.

to your dtOptions. The default value of order is [[0, 'asc']], setting it to [] will prevent dataTables from making an initial sort on the first column after initialisation.

这篇关于如何禁用Angular Datatables中数据的初始排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆