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

190
Views
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 answers
Answer question

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 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!