diff --git a/Scripts/custom.js b/Scripts/custom.js index d14dfa838..a8c3d1b85 100644 --- a/Scripts/custom.js +++ b/Scripts/custom.js @@ -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(); }