Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda