Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

290
Views
Formatear números usando DataTables rompe la clasificación

Tengo tablas que estoy tratando de ordenar, el problema es que cuando agrego locales a los números, se interrumpe la ordenación, se ordenan como si fueran cadenas.

Seguí esta respuesta y modifiqué sin tener que usar expresiones regulares, pero luego comienza a clasificar como cadenas y ya no números, por ejemplo

 1 1.200 2
 $(document).ready(function () { $('.my_table').DataTable({ "bProcessing": true, "bPaginate": true, "bDestroy": true, "bShowPollInfo": false, "iDisplayLength": 20, "aLengthMenu": [[20, 40, -1], [20, 40, "_all"]], "sScrollX": "100%", "aoColumns": [ { "sWidth": "160px", "sClass": "nowrap" }, ], "aoColumnDefs": [ { "mRender": function (data, type, row) { return formatNumbers(data); }, "aTargets": [1, 2] }, ], }); }); function formatNumbers(val) { return parseInt(val).toLocaleString("de-DE"); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Cambie la parte "aoColumnDefs" a esto

 "aoColumnDefs": [ { "mRender": function (data, type, row) { if( type === 'display' ){ return formatNumbers(data); // only format the data for display }else{ return data; // the default data should be used for sorting } }, "aTargets": [1, 2] }, ],
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!