I have implemented the basic example at https://www.datatables.net/

I have implemented the basic example at https://www.datatables.net/

evanhughesevanhughes Posts: 2Questions: 2Answers: 0
edited December 2015 in Free community support

The problem I'm having is when I take my data and convert rows to columns.

table_the_results = """ SELECT sku,\
MAX(CASE WHEN sku_attr = 'base_sku' THEN value END) base_sku,\
MAX(CASE WHEN sku_attr = 'model' THEN value END) model,\
MAX(CASE WHEN sku_attr = 'mclass' THEN value END) mclass,\
MAX(CASE WHEN sku_attr = 'netcfg' THEN value END) netcfg,\
MAX(CASE WHEN sku_attr = 'preconfig' THEN value END) preconfig,\
MAX(CASE WHEN sku_attr = 'second_sw' THEN value END) second_sw,\
MAX(CASE WHEN sku_attr = 'boot_second' THEN value END) boot_second,\
MAX(CASE WHEN sku_attr = 'serial_prefix' THEN value END) serial_prefix \
FROM sku_view GROUP BY sku ORDER BY sku """

When I view this I need to do the following in my template. Since the above does not put names to the values so that I could modify the code below to be value.sku, value.base_sku, etc. the following does not display any data "if" I'm using DataTables. Otherwise it displays fine.

I need some help on how to make the query loop below work. I have other views that are working great, but those don't require I display with value.0, value.1, etc. In those other working views, because I'm getting data straight from the db table I would have, for instance, value.sku, value.base_sku, etc.

I understand that because the data generated by the Select statement above does not have field name identifiers for each field. I THINK.

{% for value in queryset %}
<tbody>
<tr>
<td>{{ value.0 }}</td>
<td>{{ value.1 }}</td>
<td>{{ value.2 }}</td>
<td>{{ value.3 }}</td>
<td>{{ value.4 }}</td>
<td>{{ value.5 }}</td>
<td>{{ value.6 }}</td>
<td>{{ value.7 }}</td>
<td>{{ value.8 }}</td>
</tr>
</tbody>

This discussion has been closed.