Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
Sort bootstrap table by column specified with index

By default bootstrap table is sorted using the first column. This setting can be changed with data-sort-name="column_name" data-sort-order="asc/desc" as mentioned here link.

In my scenario the column names are created dynamically based on a python script. As such the data-sort-name option is not helpful.

Is it possible to specify the column I want the default sorting to be done by the column index?

  <table id="table_example"
     class="table table-striped"
     data-toggle="table"
<thead>
  <tr>
    {% for col in column_names %}
    <th>{{col}}</th>
    {% endfor %}
  </tr>
</thead>
<tbody>
{% for row in row_data %}
    <tr>
    {% for col, row_ in zip(column_names, row) %}
    <td>{{row_}}</td>
    {% endfor %}
    </tr>
  {% endfor %}
</tbody>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I've solved the problem by adding the following script with column index 1:

 <script>
    $(document).ready(function () {
      $('#table_example').DataTable({
      "order": [[ 1, "desc" ]]
      });
    });
  </script>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda