You need to sign in to do that
Don't have an account?
Suresh Raghuram
issue with the picklist
<apex:pageBlockSectionItem >
<apex:outputLabel value="Product Group" for="prodgroup"/>
<apex:selectList id="prodgroup" value="{!selectedProductGroup}" size="1" title="ProductGroup">
<apex:selectOptions value="{!productGroupOptions}"></apex:selectOptions>
</apex:selectList>
</apex:pageBlockSectionItem>
public string selectedProductGroup{get;set;}
public List<selectOption> getProductGroupOptions() {
List<selectOption> options = new List<selectOption>();
//options.add(new selectOption('', '- None -'));
for (Product_List__c ProdGroup : [Select Id, Name from Product_List__c]) {
options.add(new selectOption(ProdGroup .name, ProdGroup .Name));
}
options.sort();
return options; //return the picklist options
}
so far it is fine. I am gettiing values in the Picklist .
But the issue is When I want to use the selected picklist value and show another picklist values.
I noticed I am not getting a value into selectedProductGroup of the picklist.
Can some one correct me where I am making wrong.
<apex:outputLabel value="Product Group" for="prodgroup"/>
<apex:selectList id="prodgroup" value="{!selectedProductGroup}" size="1" title="ProductGroup">
<apex:selectOptions value="{!productGroupOptions}"></apex:selectOptions>
</apex:selectList>
</apex:pageBlockSectionItem>
public string selectedProductGroup{get;set;}
public List<selectOption> getProductGroupOptions() {
List<selectOption> options = new List<selectOption>();
//options.add(new selectOption('', '- None -'));
for (Product_List__c ProdGroup : [Select Id, Name from Product_List__c]) {
options.add(new selectOption(ProdGroup .name, ProdGroup .Name));
}
options.sort();
return options; //return the picklist options
}
so far it is fine. I am gettiing values in the Picklist .
But the issue is When I want to use the selected picklist value and show another picklist values.
I noticed I am not getting a value into selectedProductGroup of the picklist.
Can some one correct me where I am making wrong.
The above code is good, but If you can provide more code as you mention show other picklist values. Then it easy to find out the solution.
List<selectOption> options = new List<selectOption>();
//options.add(new selectOption('', '- None -'));
for (Product_Value__c ProdGroup : [Select Id, Value from Product_Value__c where Group__c =:
selectedProductGroup]) {options.add(new selectOption(ProdGroup .name, ProdGroup .Name));
}
options.sort();
return options; //return the picklist options
}
the striked oneis the value where my second picklist is looking for. Bu treceiving no value. did i made any mistake defining its property.
I have done the same kind of thing previously to show the contacts based on the account name selected in the picklist.
please find the below code:
******************************
Page:
********
<apex:page>
<apex:form>
<apex:sectionHeader title="Select Account to see the contact details in the below table"/>
<apex:outputPanel id="out">
<apex:selectList value="{!selectedAccount}" size="1">
<apex:selectOptions value="{!Lst}"/>
</apex:selectList>
<apex:actionSupport event="onchange" action="{!showAccount}" rerender="out"/>
<apex:dataTable value="{!CLst}" var="C" border="1" width="100%" headerClass="color:blue">
<apex:column value="{!C.name}" headerValue="Contact name" width="20%"/>
<apex:column value="{!C.phone}" headerValue="Contact Phone" width="20%"/>
<apex:column value="{!C.email}" headerValue="Contact Email" width="20%"/>
</apex:dataTable>
</apex:outputPanel>
</apex:form>
</apex:page>
Controller:
************
public class ConCls {
public selectOption[] Lst { get; set; }
public string selectedAccount { get; set; }
public string AccId { get; set; }
Public contact[] CLst { get; set; }
public ConCls(){
Alst = [SELECT Id,name from Account];
Lst = new selectOption[]{};
Lst.add(new selectOption('','--Please select an Account--'));
for(Account A :Alst){
Lst.add(new SelectOption(A.Id,A.name));
}
}
public void showAccount(){
//System.debug('--SelectedAccount--'+selectedAccount);
//AccId = [Select Id,name from Account WHERE Id =: selectedAccount Limit 1].Id;
//system.debug('-----'+AccId);
CLst = new contact[]{};
CLst = [SELECT Id,name,email,phone FROM Contact WHERE AccountId =:selectedAccount];
}
}
Thanks,
Vijay