我创建了表
<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>
使用第一列顺序加载的表:
NannieID
id1
id10
id12
id13
id2
id3
id5
我希望每次点击重新排序和第一次加载时获得正确的顺序。 预期结果:
NannieID
id1
id2
id3
id5
id10
id12
id13
我添加了这段代码,但只有在加载表时才有帮助,点击重新排序列之后,我输错了订单
$scope.options = DTOptionsBuilder.newOptions().withOption('aaSorting', [[5, 'asc']])
请帮帮我
答案 0 :(得分:7)
将static {
// avoid error javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name
System.setProperty("jsse.enableSNIExtension", "false");
}
public static HttpClientBuilder createTrustAllHttpClientBuilder() {
try {
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial(null, (chain, authType) -> true);
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(), NoopHostnameVerifier.INSTANCE);
return HttpClients.custom().setSSLSocketFactory(sslsf);
}
catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
throw new IllegalStateException(e);
}
}
更改为aaSorting
。你的代码就像:
order
答案 1 :(得分:0)
您可以使用 javascript 函数sort
$scope.asc = false;
$scope.reorder = function(direction){
items.sort(function(a, b) {
return a.id - b.id;
});
if(asc){
items.reverse();
asc = false;
}
}
添加一个ng-click
来电reorder
<button ng-click="$scope.reorder()">Reorder</button>
每次按下Reorder
按钮,您的列表都会从Asc Order
和Desc Order
切换