Sort differently with . each

Asked

Viewed 39 times

0

I have a screen that lists some skills, they come from the bank in the following format.

JSon competencias

The last two are the pays that are OK and right after it starts the rest, where 0219 is February/2019, 0319 March/2019 and so on. But in my listing I need it to display the next competency that would be 0219 and not the last one 01/20 (January/2020).

atual

The code that builds these fields is this.

$.each(json.ext, function(k,v){
                inpsel = (parseFloat(v.valor_pago) == 0.0) 
                       ? `<td><input type="checkbox" value="`+ v.seq_movimento_cobranca +`" name="seq_movimento_cobranca[]" onclick="verificaBaixaManual()" data-vlr="`+ v.valor_devido +`"/>` +`</td>`
                       : `<td>&nbsp;</td>`;
                v.data_pagamento = (v.data_pagamento == null) ? '-' : v.data_pagamento;
                tbl += `<tr style="text-align:right" class="`+ v.tr_color +` tr-`+ v.seq_movimento_cobranca +`">`
                    + inpsel
                    + `<td>`+ v.data_vencimento +`</td>`
                    + `<td>`+ v.competencia +`</td>`
                    + `<td>`+ v.valor_devido.replace('.', ',') +`</td>`
                    + `<td>`+ v.taxa +`</td>`
                    + `<td>`+ v.data_pagamento +`</td>`
                    + `<td style="">`+ v.valor_pago.replace('.', ',') +`</td>`
                    + `</tr>`;
            });
  • Have you tried playing the values in an array instead of directly in the tbl variable, reversing the array order and then playing in the variable? I’m running out of time to write the answer now, but I think that solves your problem if you just want to reverse the order in which the table receives the data.

  • I think I’ve got it all figured out, but thanks buddy.

  • So it would be interesting if you put your solution as an answer or else close the question

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.