1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-10 01:17:59 +03:00

Fixed date columns sorting (marked as "uds-date" type, and made custom sorting methods for datatable)

This commit is contained in:
Adolfo Gómez 2013-12-17 10:03:51 +00:00
parent edc03f4e7e
commit 3b570f86df
3 changed files with 21 additions and 5 deletions

View File

@ -164,14 +164,15 @@ GuiElement.prototype = {
if (opts.type && column.bVisible ) {
switch(opts.type) {
case 'date':
column.sType = 'date';
column.sType = 'uds-date';
column.mRender = gui.tools.renderDate(api.tools.djangoFormat(get_format('SHORT_DATE_FORMAT')));
break;
case 'datetime':
column.sType = 'date';
column.sType = 'uds-date';
column.mRender = gui.tools.renderDate(api.tools.djangoFormat(get_format('SHORT_DATETIME_FORMAT')));
break;
case 'time':
column.sType = 'uds-date';
column.mRender = gui.tools.renderDate(api.tools.djangoFormat(get_format('TIME_FORMAT')));
break;
case 'iconType':
@ -551,7 +552,9 @@ GuiElement.prototype = {
var columns = [
{
"mData" : 'date',
"sTitle" : gettext('Date'),
"sTitle" : gettext('Date'),
"sType": "uds-date",
"asSorting": [ 'desc', 'asc' ],
"mRender" : gui.tools.renderDate(api.tools.djangoFormat(get_format('SHORT_DATE_FORMAT') + ' ' + get_format('TIME_FORMAT'))),
"bSortable" : true,
"bSearchable" : true,

View File

@ -68,7 +68,7 @@
// Datetime renderer (with specified format)
renderDate : function(format) {
return function(data, type, full) {
return api.tools.strftime(format, new Date(data*1000));
return '<span data-date="' + data + '">' + api.tools.strftime(format, new Date(data*1000)) + '</span>';
};
},
// Log level rendererer

View File

@ -226,6 +226,20 @@
});
// Set blockui params
$.blockUI.defaults.baseZ = 2000;
$.fn.dataTableExt.oSort['uds-date-pre'] = function( s ) {
return parseInt(s.split('"')[1]);
};
// Sort for "date" columns (our "dates" are in fact postfix dates rendered as dates with locale format
$.fn.dataTableExt.oSort['uds-date-asc'] = function(x,y) {
var val = ((x < y) ? -1 : ((x > y) ? 1 : 0));
return val;
};
$.fn.dataTableExt.oSort['uds-date-desc'] = function(x,y) {
var val = ((x < y) ? 1 : ((x > y) ? -1 : 0));
return val;
};
gui.setLinksEvents();
gui.dashboard.link();
@ -334,4 +348,3 @@
// Public attributes
gui.debug = true;
}(window.gui = window.gui || {}, jQuery));