I have incident report. If the user types in 3, 3 rows appear to describe each incident.
The two columns to the write of the page, "Employee" and "Opportunity (Patient)". I want neither of the fields to display if the "Affected Population" value in the row is selected to "--None---",
Only the employee field to display if "Affected Population" value in the row is set to "Employee",
etc
Here is the visualforce code for those Affected Population and two columns on the right
<!--Infection Incidents Section -->
<apex:pageBlockSection title="Infection Incidents : {!InfectionCount}" columns="1" id="infecIncidentsec" showHeader="false">
<apex:pageBlockTable style="width:100%" value="{!Infections}" var="item" rendered="{!Infections.size > 0}">
<apex:column style="width:11%;" headerValue="Date of Incident">
<apex:inputField value="{!item.DateOfIncident__c}" required="true"/>
</apex:column>
<apex:column style="width:11%;" headerValue="Affected Population">
<apex:inputField value="{!item.Affected_Population__c}" required="true" onchange="showFields(this)" styleClass="affecPopulateList">
<apex:actionSupport event="onchange" rerender="colEmp, colOpp"/>
</apex:inputField>
</apex:column>
<apex:column style="width:11%;" headerValue="Infected on Admission">
<apex:OutputPanel layout="block" styleClass="requiredInput infecInItem patient" >
<span>
<apex:OutputPanel styleClass="requiredBlock"/>
<apex:inputField value="{!item.Infection_Present_on_Admission__c}" styleClass="infecInInputItem patientinfecInInputItem infecRequired"/>
<div class="errorMsg" style="display:none">
<strong></strong>
You must enter a value.
</div>
</span>
</apex:OutputPanel>
</apex:column>
<apex:column style="width:11%" headerValue="Employee" id="colEmp">
<apex:OutputPanel layout="block" styleClass="requiredInput infecInItem employee" >
<span>
<apex:OutputPanel styleClass="requiredBlock" />
<apex:inputField style="width:80%" value="{!item.Employee__c}" styleClass="infecInInputItem employeeinfecInInputItem infecRequired" rendered="{!item.Affected_Population__c == 'Employee' }"/>
<div class="errorMsg" style="display:none">
<strong></strong>
You must enter a value.
</div>
</span>
</apex:OutputPanel>
</apex:column>
<apex:column style="width:56%;" headerValue="Opportunity (Patient)" id="colOpp">
<apex:OutputPanel layout="block" styleClass="requiredInput infecInItem patient" >
<span>
<apex:OutputPanel styleClass="requiredBlock"/>
<apex:inputField style="width:15%" value="{!item.Opportunity__c}" styleclass="infecInInputItem patientinfecInInputItem infecRequired" rendered="{!item.Affected_Population__c != '' }"/>
<div class="errorMsg" style="display:none">
<strong></strong>
You must enter a value.
</div>
</span>
</apex:OutputPanel>
</apex:column>
I know there is a rendered property for the apex:column component, but my if statement doesn't appear to be working
rendered="{! If(item.Affected_Population__C == "Employee",true,false) }"
<apex:component>
tag to make the logic more modular. Just a thought. – Adrian Larson♦ Aug 24 '16 at 23:14