I have a Django-tables2 rendered HTML table and I want to extract the values from the first three columns to use them as arguments in another template.
{% block table %}
<table id="myTable" class="table table-striped table-hovered table-bordered table-condensed"{% if table.attrs %} {{ table.attrs.as_html }}{% endif %}>
{% block table.thead %}
<thead>
<tr>
{% for column in table.columns %}
{% if column.orderable %}
<th {{ column.attrs.th.as_html }}><a href="{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}">{{ column.header }}</a></th>
{% else %}
<th {{ column.attrs.th.as_html }}>{{ column.header }}</th>
{% endif %}
{% endfor %}
</tr>
</thead>
{% endblock table.thead %}
{% block table.tbody %}
<tbody>
{% for row in table.page.object_list|default:table.rows %} {# support pagination #}
{% block table.tbody.row %}
<tr class="{% cycle 'odd' 'even' %}">
{% for column, cell in row.items %}
<td {{ column.attrs.td.as_html }}>{{ cell }}</td>
{% endfor %}
</tr>
{% endblock table.tbody.row %}
{% endfor %}
</tbody>
{% endblock table.tbody %}
{% block table.tfoot %}
<tfoot></tfoot>
{% endblock table.tfoot %}
</table>
{% if table.page %}
{% block pagination %}
{% bootstrap_pagination table.page %}
{% endblock pagination %}
{% endif %}
{% endblock table %}
My requirement is to fetch values from the initial three columns and utilize them as arguments. In the fourth column, there is a dropdown button created using a JavaScript function. I can insert text with a JS function, but I'm uncertain about passing the cell value to the input cell. If I modify this line:
<td {{ column.attrs.td.as_html }}>{{ cell }}</td>
to this:
<td {{ column.attrs.td.as_html }}><input type="text" value="{{ cell }}"</td>
The conversion works, but all cells turn into input texts, whereas I only aim to convert the first three columns.