[print] Hide columns with zero value

This commit is contained in:
Anand Doshi 2014-08-05 16:38:19 +05:30
parent a5a8830b56
commit c157b5b57e

View file

@ -221,11 +221,19 @@ def get_visible_columns(data, table_meta):
return columns
def column_has_value(data, fieldname):
"""Check if at least one cell in column has non-zero and non-blank value"""
has_value = False
for row in data:
if row.get(fieldname) is not None:
has_value = True
break
value = row.get(fieldname)
if value:
if isinstance(value, basestring):
if strip_html(value).strip():
has_value = True
break
else:
has_value = True
break
return has_value