+ Start a Discussion

How do I display fields off Select Box?


   I have a dropdown which contains the record types. Now I would like to display fields off that record type based on what the user selected. Does anyone have an example of this? 




if your dropdown list's value is bound to a controller variable (say a String), you can use that String as a query param against a record from RecordType that you use to bind to form elements.  Rerender the container for the form elements after selectedIndex changes on the dropdown list.  that will ensure your content is refreshed when you have a different record type


I tried using rerender and I get an error stating

 Unsupported attribute rerender in <apex:inputField>???? My VF Page below


<apex:page controller="QuoteRecordTypeController" title="Insert Multiple Quotes"> <apex:form > <apex:pageBlock title="Insert Multiple Quotes"> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}" rerender="error,table"/> <apex:commandButton value="Cancel" action="{!cancel}" rerender="error,table" immediate="true"/> </apex:pageBlockButtons> <apex:pageMessages ></apex:pageMessages> <apex:messages /> <apex:pageBlockSection id="selectedRecordType" columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel value="Choose Record Type for batch of Quotes" for="rt" /> <apex:panelGrid columns="2"> <apex:selectList value="{!RecordType}" multiselect="false" size="1"> <apex:selectOptions value="{!rectypes}"/> </apex:selectList> </apex:panelGrid> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockTable value="{!over}" var="a" id="table"> <apex:column headerValue="Placement"> <apex:inputField value="{!a.Placement_Lookup__c}" required="true" /> </apex:column> <apex:column headerValue="Hotel Room"> <apex:inputField value="{!a.Hotel_Room_Lookup__c}" required="true" /> </apex:column> <apex:column headerValue="Adjustment"> <apex:inputField value="{!a.Adjustment_Lookup__c}" required="true" rerender="{!RecordType=='Adjustment Quote'}"/> <!--Only If Record Type is Adjustment Quote--> </apex:column> <apex:column headerValue="Extension"> <apex:inputField value="{!a.Extension_Lookup__c}" required="true" /> </apex:column> </apex:pageBlockTable> <apex:pageblockButtons location="bottom"> <div style="text-align:right;margin-right:30px;font-weight:bold;"> <apex:commandLink value="Add Row" action="{!addRow}" rerender="table,error" immediate="true" /> &nbsp;|&nbsp;&nbsp; <apex:commandLink id="RemoveRow" value="Remove Row" action="{!removeRow}" rerender="table,error" immediate="true" /> </div> </apex:pageblockButtons> </apex:pageBlock> </apex:form> </apex:page>







I want to display left most column  as a checkbox field in the pageblock table, i am getting this error message Unsupported attribute headervalue in <apex:inputField> in Quote at line 10 column 155. I tried with data table also  getting same error message,Can any one help me here.


Below is my code:


VF page:

<apex:page standardController="Opportunity" extensions="QuoteController" sidebar="false" id="pg" showHeader="false">
<script src="/soap/ajax/25.0/connection.js" type="text/javascript"></script>
<script src="/soap/ajax/25.0/apex.js" type="text/javascript"></script>
<body style="background-image:url({!$Resource.sampleImage1});">
<apex:form id="QuoteList">
<apex:pageBlock id="membersTable" tabstyle="Opportunity">

<apex:pageBlockTable value="{!quoteList}" var="a" columns="7">
<apex:inputField value="{!qObj.Quote_Selection__c" he/>
<apex:column value="{!a.Name}" headerValue="Quotes">
<apex:facet name="header">
<apex:commandLink action="{!orederQuoteList}" value="{!$ObjectType.Quote__c.fields.Name.label}{!IF(sortExpression=='quote__C.Name',IF(sortDirection='ASC','▼','▲'),'')}">
<apex:param value="quote__C.Name" name="column" assignTo="{!sortExpression}" ></apex:param>







public class QuoteController{
public List<Quote__c> quoteList{get;set;}
private Opportunity opty;
public Id optyId;
private String sortExp = 'quote__C.Name';
private String sortExp1 = 'quote__C.Quote_Version__c';
private String sortDirection = 'ASC';
private String sortDirection1 = 'ASC';
public Quote__c qObj{get;set;}

public quoteController(ApexPages.StandardController controller)
//opty = new Opportunity();
this.opty = (Opportunity)controller.getRecord();
this.optyId = opty.id;
quoteList = [select id,name,Quote_End_Date__c,Quote_Version__c from Quote__c where Opportunity__c =:optyId order by name asc];
this.qObj = [select id,name,Quote_Selection__c from Quote__c where Opportunity__c =:optyId];

public pageReference orederQuoteList()
quoteList = new List<Quote__c>();
//quoteList = [select id,name,Quote_End_Date__c,Quote_Version__c from Quote__c where Opportunity__c =:optyId];
system.debug('sortExpression value is: '+sortExpression);
system.debug('sortDirection value is: '+sortDirection);
String sortFullExp = sortExpression + ' ' + sortDirection +',' +sortExpression1+' ' + sortDirection1;
system.debug('sort FullExpression value is: '+sortFullExp);
String query = 'select id,name,Quote_End_Date__c,Quote_Version__c from Quote__c where Opportunity__c = \'' + optyId+ '\'' + 'order by '+sortFullExp;
quoteList = Database.query(query);
return null;




Thanks in Advance.........