django-tables2
django-tables2 copied to clipboard
BoundRow allow getting key and value for columns
Right now in the template you loop through the columns to display the headers.
Then you loop through the rows and for each row through the values.
It would have real added value if you could look through the values and also get the corresponding column name for that value. That way you can for instance add special conditions in your template to turn a value into a link or something like that.
So something like:
{% for column, value in item.iteritems %} ... {% endfor %}
instead of:
{% for value in item.values %} ... {% endfor %}
I think me might be able to solve this using the changes in Kevin's branch (179fc7a4d04578fc93849a5d7755a7d97e7351db - see also the comments), which would allow something like:
{% for value in row %} {{ row.column }} {% endfor %}
that allows you to set properties on the column and pass them to the different cells. What I need is in the template a way to know which column I'm currently outputting the value for.
You would have to modify it, to pass the colum object to the cell on lines 359 and 362. And ofcourse store it on the column init.
Yes, that's the plan. Turns out Github doesn't show the comments in the above link, but you can see them here:
http://github.com/isolationism/django-tables/commit/179fc7a4d04578fc93849a5d7755a7d97e7351db