Enable sorting columns in servers table on review page

Change-Id: Ia43d066feaaf925dd09d34d520210388dc11b471
This commit is contained in:
jiahuay 2014-02-24 17:16:46 -08:00
parent 7578e35099
commit 533897d4e6
2 changed files with 41 additions and 8 deletions

View File

@ -26,7 +26,7 @@ steal(
} else {
this.element.html(this.view('init'));
this.dataTableIpAddrSort();
this.initServerTable();
this.onSecurityData(this.options.odsState.security);
@ -91,6 +91,36 @@ steal(
$("#storage_end").html(data.interfaces.storage.ip_end);
},
dataTableIpAddrSort: function() {
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
"ip-address-pre": function(a) {
var m = a.split("."),
x = "";
for (var i = 0; i < m.length; i++) {
var item = m[i];
if (item.length == 1) {
x += "00" + item;
} else if (item.length == 2) {
x += "0" + item;
} else {
x += item;
}
}
return x;
},
"ip-address-asc": function(a, b) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"ip-address-desc": function(a, b) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
});
},
initServerTable: function() {
this.dataTable = $('#tb_server_review').dataTable({
"sScrollY": "450px",
@ -101,11 +131,14 @@ steal(
}, {
"mData": "mac"
}, {
"mData": "management_ip"
"mData": "management_ip",
"sType": "ip-address"
}, {
"mData": "tenant_ip"
"mData": "tenant_ip",
"sType": "ip-address"
}, {
"mData": "switch_ip"
"mData": "switch_ip",
"sType": "ip-address"
}, {
"mData": "port"
}, {
@ -122,7 +155,7 @@ steal(
}],
"aoColumnDefs": [{
bSortable: false,
aTargets: [0, 1, 2, 3, 6]
aTargets: [1, 6]
}],
"aaSorting": [
[4, "asc"],

View File

@ -85,15 +85,15 @@ table.display thead th {
}
.sorting {
background: url('../../../img/bg.gif') no-repeat 60% 50%;
background: url('../../../img/bg.gif') no-repeat 70% 50%;
}
.sorting_desc {
background: url('../../../img/desc.gif') no-repeat 60% 50%;
background: url('../../../img/desc.gif') no-repeat 70% 50%;
}
.sorting_asc {
background: url('../../../img/asc.gif') no-repeat 60% 50%;
background: url('../../../img/asc.gif') no-repeat 70% 50%;
}
.highlight {