I have a report requirement where the columns will need to be dynamically created. I have looked through the report documentation and have not found anything discussing a way to add or remove columns dynamically in a report. Is there some way to do this?
Hello,
because jmix reports is very flexible there would be multiple ways to go about that as i see it. Largely depeding on your choice of template.
Maybe for a html template you could have a datasource that specifies the columns, lets call it data
and then create the columns based on that:
not tested
i <table class="report-table" cellspacing="2">
<thead>
<tr>
<#list data as col>
<th>${col.fields.name}</th>
</#list>
</tr>
</thead>
<tbody>
<#list rows as row>
<tr>
<#list data as col>
<td>${row.fields.col[col]}</td>
</#list>
</tr>
</#list>
</tbody>
</table>
If you know your columns in advance and just want to hide/show depinding on available data you could also use japser with an expression on the column: Hide and Show table columns based on condition in jasper - Helical IT Solutions Pvt Ltd
Japser may also have additional ways to solve dynamic columns (crosstabs, …)
BR
1 Like
Yes that is perfect. Thank you!