function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
business Identitybusiness Identity 

How to make a column in DataTable visible/invisible

Hello people!

I need a way to access the column in the apex datatable in javascript, so that I can enable/disable its visibility. I tried the thing with 

document.getElementById('{!$Component.emp_bim:emp_frm:crt_emp}').style.display="none";

kind of statements but couldn't get it. In the Below code, I dont want the column 'edit' to be displayed (on some condition of course). Little help here..! Thanks


<apex:dataTable id="emp_dttbl" value="{!emp_lst}" rowClasses="odd,even" var="employee" border="0" cellpadding="5px">
<apex:column >
        <apex:facet name="header">Edit</apex:facet>
<apex:image id="emp_udt" alt="{!employee.Id}" height="25px" width="25px" onclick="expandUpdate(this)" url="{!$Resource.update_icon}"/>
</apex:column>
<apex:column >
        <apex:facet name="header">Delete</apex:facet>
        <apex:image id="emp_del" alt="{!employee.Id}" height="25px" width="25px" onclick="callDelete(this)" url="                                                {!$Resource.delete_icon}"/>
</apex:column>
</apex:dataTable>
NekosanNekosan
Did you try giving styleclass to apex:column and then use document.getElementsByClassName()?
business Identitybusiness Identity
Yes Buddy. But its not working that way... :(