在角度“数据表"中对列进行排序 [英] Sort column in angular 'datatables'

查看:97
本文介绍了在角度“数据表"中对列进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了表格

<table class="table table-striped table-bordered table-hover" width="100%" datatable="ng" dt-options="options">
<thead>
<tr>
    <th> Nannie ID</th>
    <th> Name</th>
    <th> Last name</th>
    <th> Email</th>
</tr>
</thead>
<tbody>
<tr class="" ng-repeat='item in items'>
    <td><a ui-sref="admin.nanniesEdit({id:item.id})">id{{item.id}}</a></td>
    <td>{{item.profile.name}}</td>
    <td>{{item.lastname}}</td>
    <td>{{item.profile.email}}</td>
</tr>
</tbody>

按第一列顺序加载的表:

Table loaded with first column order:

NannieID
id1 
id10    
id12    
id13    
id2 
id3 
id5 

我希望每次重新点击以及首次加载时都获得正确的订单. 预期结果:

I want get correct order for each click reorder, and when first loading. Expected result:

NannieID
id1 
id2 
id3 
id5 
id10    
id12    
id13    

我添加了此代码,但仅在加载表时有用,单击重新排序列后,我得到了错误的顺序

I added this code, but it helped only when table is loading, after click for reorder column, I got wrong order

$scope.options = DTOptionsBuilder.newOptions().withOption('aaSorting', [[5, 'asc']])

请帮帮我

推荐答案

aaSorting更改为order.您的代码如下:

Change the aaSorting to order. Your code will be like:

$scope.options = DTOptionsBuilder.newOptions().withOption('order', [[5, 'asc']])

这篇关于在角度“数据表"中对列进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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