I created table
<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']])
Please, help me
Change the
aaSorting
toorder
. Your code will be like:You can reorder the array of objects with the javascript function
sort
And add a button with an
ng-click
callingreorder
Every time you press the
Reorder
button, your list is going to switch fromAsc Order
andDesc Order