This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2024-01-15 20:01:27 -07:00
parent 8dce44280f
commit 1f1965af8d

View File

@@ -1667,6 +1667,22 @@ function loadsortadscroll() {
var index = tthis.index();
var multiplicador = -1;
var tipodato = tthis.closest('tr').find('th').data('tipodato')
if(1==1){
var table = $(tthis.closest('.ADScroller').find('.ADScroller-body > table ')[0]);
var tabletr = table.find('> tr:not(.trnopadding.ADtr),> tbody > tr:not(.trnopadding.ADtr),> thead > tr:not(.trnopadding.ADtr)');
if (tabletr.length > 0) {
el = $(tabletr[0]);
var tdtexto = el.find("> td");
texto = $(tdtexto[index]).data('order');
if (texto) {
tipodato = 'dataorder';
}
}
}
console.log({ tipodato })
tthis.closest('tr').addClass('tsorterblock');
setTimeout(
function () {
@@ -1867,6 +1883,43 @@ function loadsortadscroll() {
table.append(this.obj);
});
}
function reordenarcinco() {
var re = new RegExp(",", 'g');
var table = $(tthis.closest('.ADScroller').find('.ADScroller-body > table ')[0]);
var tabletr = table.find('> tr:not(.trnopadding.ADtr),> tbody > tr:not(.trnopadding.ADtr),> thead > tr:not(.trnopadding.ADtr)');
tipostring = 0;
tiponumeric = 0;
tipodate = 0;
var mapped = tabletr.map(function (i, el) {
el = $(el);
var tdtexto = el.find("> td");
var texto = null;
var texton = 0;
if (tdtexto && tdtexto.length > index) {
texto = $(tdtexto[index]).data('order');
if (texto.length > 0) {
var vnum = texto.replace("$", "").replace("%", "").replace("-", "").replace("(", "").replace(")", "").replace(re, "").trim();
if (vnum.length > 0) {
if ($.isNumeric(vnum)) {
texton = Number(vnum);
}
}
}
} else {
texto = null;
}
return { index: i, value: texton, obj: el };
});
console.log(mapped)
mapped.sort(function (a, b) {
return (+(a.value > b.value) || +(a.value === b.value) - 1) * multiplicador;
});
mapped.each(function (i, el) {
table.append(this.obj);
});
}
switch (tipodato) {
case 'string':
reordenardos();
@@ -1877,6 +1930,9 @@ function loadsortadscroll() {
case 'numeric':
reordenarcuatro();
break;
case 'dataorder':
reordenarcinco();
break;
default:
reordenaruno();
}