+ Start a Discussion
S SaiS Sai 

datatable dependent picklist in visualforce

Hi All,

i want to display dependent pick list in a table. In a table having 2 picklist Columns when i am selecting table column picklist1 then display the table column2 pick list values

Thanks
SS 
salesforce mesalesforce me
hi check this once...
 
<apex:page controller="MyController">
    <apex:form id="theForm">
        <apex:sectionHeader title="Choose Product"/>
        <apex:pageBlock title="Demo Page">
            <apex:pageBlockSection columns="1">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel >Group</apex:outputLabel>
                    <apex:selectList size="1" multiselect="false" value="{!currentGroup}">
                        <apex:selectOptions value="{!ListGroups}"/>
                        <apex:actionSupport reRender="theForm" event="onchange"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel >Product</apex:outputLabel>
                    <apex:selectList value="{!currentProduct}" size="1" multiselect="false">
                        <apex:selectOptions value="{!listProducts}"/>
                        <apex:actionSupport reRender="theForm" event="onchange"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel >TUC</apex:outputLabel>
                    <apex:selectList value="{!currentTuc}" size="1" multiselect="false">
                        <apex:selectOptions value="{!listTucs}"/>
                        <apex:actionSupport reRender="theForm" event="onchange"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel >Description</apex:outputLabel>
                    <apex:outputText >{!tucDescribe}</apex:outputText>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
apex code for:---
 
public with sharing class MyController {
    public string currentGroup { get; set; }
    public string currentProduct { get; set; }
    public string currentTuc { get; set; }

    public MyController() {
        currentGroup = currentProduct = currentTuc = null;
    }
    
    public List<SelectOption> getListGroups() {
        List<SelectOption> options = new List<SelectOption> { new SelectOption('','-- Choose --') };
        for(Schema.PicklistEntry pe:Product2.Family.getDescribe().getPicklistValues()) {
            options.add(new SelectOption(pe.getValue(),pe.getLabel()));
        }
        return options;
    }
    
    public List<SelectOption> getListProducts() {
        List<SelectOption> options = new List<SelectOption>();
        if(currentGroup == null || currentGroup == '')
            return options;
        options.add(new SelectOption('','-- Choose --'));
        for(Product2 p2:[select id,name from product2 where family = :currentGroup]) {
            options.add(new SelectOption(p2.id,p2.name));
        }
        return options;
    }
    
    public List<SelectOption> getListTUCs() {
        List<SelectOption> options = new List<SelectOption>();
        if(currentProduct==null || currentProduct == '')
            return options;
        options.add(new SelectOption('','-- Choose --'));
        for(TUC__c tuc:[select id,name from tuc__c where product__c = :currentProduct]) {
            options.add(new SelectOption(tuc.id,tuc.name));
        }
        return options;
    }

    public String getTucDescribe() {
        if(currentTuc == null || currentTuc == '')
            return '';
        return [select description__c from tuc__c where id = :currentTuc].description__c;
    }
}


 
salesforce mesalesforce me
check this once also:-

http://salesforce.stackexchange.com/questions/22863/how-to-perform-dependent-picklist-operation-in-visualforce-page
S SaiS Sai
HI
 Thanks for Reply I want to Display table format 

Thanks
SS