The table table is being rendered by django admin. I will not know the amount of columns, column names or row contents. What I will know is the table id result_list
.
The issue is users want tables that can sometimes have 10+ columns. I want to provide a better user experience by either allowing users to select which columns to hide/show after the table has been rendered. My thoughts where to use Datatables but having a hard time finding the correct config.
Because this code snippet will be used by the default template, the code must be agnostic to the data inside the table.
Here is a snippet that I have:
$('#result_list').dataTable({
// initializers here
});
Typical generated table looks like:
<table id="result_list">
<thead>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
</tbody>
</table>