Open QuentinFchx opened 7 years ago
@QuentinFchx OK I marked this as an enhancement, I will merge this in if anyone can do the work and create a PR!
Before this will be merged.
Just open console and run
const dataTablesScript = document.createElement('script');
dataTablesScript.src = "https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js";
dataTablesScript.onload = function () {
jQuery.fn.dataTable.ext.type.order["file-size-pre"] = function ( data ) {
var matches = data.match( /^(\d+(?:\.\d+)?)\s*([a-z]+)/i );
var multipliers = {
b: 1,
bytes: 1,
kb: 1000,
kib: 1024,
mb: 1000000,
mib: 1048576,
gb: 1000000000,
gib: 1073741824,
tb: 1000000000000,
tib: 1099511627776,
pb: 1000000000000000,
pib: 1125899906842624
};
if (matches) {
var multiplier = multipliers[matches[2].toLowerCase()];
return parseFloat( matches[1] ) * multiplier;
} else {
return -1;
};
};
$('.table').eq(1).DataTable({
columnDefs: [
{ type: "file-size", targets: 2 },
{ className: "sortable-th size-th", targets: [ 2 ] }
],
order: [[ 2, "desc" ]],
paging: false,
searching: false,
});
};
document.body.appendChild(dataTablesScript);
It's currently only possible in the main view