src/ztfy/myams/resources/js/myams-dataTables.js
changeset 136 3ea42c4b9938
parent 107 8d815267d5cb
child 142 0201f1422bd7
equal deleted inserted replaced
135:f7b7e3f21da6 136:3ea42c4b9938
    40 			"iFilteredTotal": oSettings.fnRecordsDisplay(),
    40 			"iFilteredTotal": oSettings.fnRecordsDisplay(),
    41 			"iPage":          oSettings._iDisplayLength === -1 ? 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
    41 			"iPage":          oSettings._iDisplayLength === -1 ? 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
    42 			"iTotalPages":    oSettings._iDisplayLength === -1 ? 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
    42 			"iTotalPages":    oSettings._iDisplayLength === -1 ? 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
    43 		};
    43 		};
    44 	};
    44 	};
       
    45 
       
    46 
       
    47 	/**
       
    48 	 * Custom sorting plug-in
       
    49 	 */
       
    50 	$.fn.dataTableExt.aTypes.unshift(
       
    51 		function(sData) {
       
    52 			if (sData !== null && sData.match(/^(0[1-9]|[1-2][0-9]|3[0-1])\/(0[1-9]|1[0-2])\/[0-3][0-9]{3}$/)) {
       
    53 				return 'date-euro';
       
    54 			}
       
    55 			return null;
       
    56 		}
       
    57 	);
       
    58 
       
    59 	$.fn.dataTableExt.aTypes.unshift(
       
    60 		function(sData) {
       
    61 			if (sData !== null && sData.match(/^(0[1-9]|[1-2][0-9]|3[0-1])\/(0[1-9]|1[0-2])\/[0-3][0-9]{3} - ([0-1][0-9]|2[0-3]):[0-5][0-9]$/)) {
       
    62 				return 'datetime-euro';
       
    63 			}
       
    64 			return null;
       
    65 		}
       
    66 	);
       
    67 
       
    68 	$.extend($.fn.dataTableExt.oSort, {
       
    69 
       
    70 		// numeric-comma column sorter
       
    71 		"numeric-comma-asc": function(a, b) {
       
    72 			var x = a.replace(/,/, ".").replace(/ /g, '');
       
    73 			var y = b.replace(/,/, ".").replace(/ /g, '');
       
    74 			x = parseFloat(x);
       
    75 			y = parseFloat(y);
       
    76 			return ((x < y) ? -1 : ((x > y) ?  1 : 0));
       
    77 		},
       
    78 		"numeric-comma-desc": function(a, b) {
       
    79 			var x = a.replace(/,/, ".").replace(/ /g, '');
       
    80 			var y = b.replace(/,/, ".").replace(/ /g, '');
       
    81 			x = parseFloat(x);
       
    82 			y = parseFloat(y);
       
    83 			return ((x < y) ?  1 : ((x > y) ? -1 : 0));
       
    84 		},
       
    85 
       
    86 		// date-euro column sorter
       
    87 		"date-euro-pre": function(a) {
       
    88 			var trimmed = $.trim(a);
       
    89 			if (trimmed != '') {
       
    90 				var frDate= trimmed.split('/');
       
    91 				var x = (frDate[2] + frDate[1] + frDate[0]) * 1;
       
    92 			} else {
       
    93 				x = 10000000; // = l'an 1000 ...
       
    94 			}
       
    95 			return x;
       
    96 		},
       
    97 
       
    98 		"date-euro-asc": function(a, b) {
       
    99 			return a - b;
       
   100 		},
       
   101 
       
   102 		"date-euro-desc": function(a, b) {
       
   103 			return b - a;
       
   104 		},
       
   105 
       
   106 		// datetime-euro column sorter
       
   107 		"datetime-euro-pre": function(a) {
       
   108 			var trimmed = $.trim(a);
       
   109 			if (trimmed != '') {
       
   110 				var frDateTime = trimmed.split(' - ');
       
   111 				var frDate= frDateTime[0].split('/');
       
   112 				var frTime = frDateTime[1].split(':');
       
   113 				var x = (frDate[2] + frDate[1] + frDate[0] + frTime[0] + frTime[1]) * 1;
       
   114 			} else {
       
   115 				x = 100000000000; // = l'an 1000 ...
       
   116 			}
       
   117 			return x;
       
   118 		},
       
   119 
       
   120 		"datetime-euro-asc": function(a, b) {
       
   121 			return a - b;
       
   122 		},
       
   123 
       
   124 		"datetime-euro-desc": function(a, b) {
       
   125 			return b - a;
       
   126 		}
       
   127 	});
    45 
   128 
    46 
   129 
    47 	/**
   130 	/**
    48 	 * Bootstrap style pagination control
   131 	 * Bootstrap style pagination control
    49 	 */
   132 	 */