I would like to hide an entire column in my displaytag table using jQuery. I have assigned the <display:column>
tag with the class='col0'
and I am able to hide the data rows using $('.col0').addClass('hidden')
.
However, for the table header, I tried inserting attribute by using $('.col0').attr('headerClass', 'hidden')
but it doesn't assign the attribute to the table header. Is there any other ways so I can add the headerClass attribute to the display column?
Edited to add code snippet:
<display:table name="..." class="table simple" pagesize="20" export="false" sort="list" bundle="..." optimised="true" decorator="...">
<display:column property="dob" key="personnel.html.dateOfBirth" class="col0" headerClass=""/>
<display:table>
<script>
//function toggled by checkbox onchange='toggleColumns(this.id)'
function toggleColumns(obj) {
if($('#'+obj).attr('checked')){
$('.'+obj).removeClass('hidden');
$('.'+obj).attr('headerClass', '');
} else {
$('.'+obj).addClass('hide');
$('.'+obj).attr('headerClass', 'hidden');
}
}
</script>
Is headerClass an attribute for the <display: column>, could you please share the code snippet to resolve the issue.