1

I have the following code(omitted everything else):

<apex:column headerValue="try1" rendered="{! s.Quote.RecordType.Name == 'Standard'}">
         <apex:inputField value="{!s.Quantity}"/>
    </apex:column>
    <apex:column headerValue="try2" rendered="{! s.Quote.RecordType.Name != 'Standard'}">
          <apex:inputField value="{!s.UnitPrice}"/>
    </apex:column>

I get the correct output if the RecordType.Name isn't = 'Standard'. Basically, I get a column with header "try2" and the values of "UnitPrice". However, if the RecordType.Name is = 'Standard', I get goofy data. I get a column with header "try2" again and the values of "Quantity"!!
Why am I getting the same header each time?

"Standard" Record type Standard record type

Not "Standard" Record type Not standard

  • can you please share a screenshot? thanks – glls Jul 25 '18 at 22:18
1

You're not meant to use the iterator variable (s) inside the rendered attribute of the apex:column. I'm kind of surprised it even compiled. The rendered attribute is meant to show or hide the entire column, not individual cells. Instead, move the rendered attribute down to the input field:

<apex:column headerValue="try1" ">
     <apex:inputField rendered="{! s.Quote.RecordType.Name == 'Standard'}" value="{!s.Quantity}"/>
</apex:column>
<apex:column headerValue="try2" >
      <apex:inputField rendered="{! s.Quote.RecordType.Name != 'Standard'}" value="{!s.UnitPrice}"/>
</apex:column>

Or, if these are all for the same quote, use the quote directly:

<apex:column headerValue="try1" rendered="{!Quote.RecordType.Name == 'Standard'}">
     <apex:inputField  value="{!s.Quantity}"/>
</apex:column>
<apex:column headerValue="try2" rendered="{!Quote.RecordType.Name != 'Standard'}">
      <apex:inputField  value="{!s.UnitPrice}"/>
</apex:column>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.