0

Anyone know how to pass a selectList inside a apexBlockTable to choice multiple SelectOptions with individual list of versions by specific product name. there are a VF and the controller method below any ideas?

PS: Please see the screenshot below for more information

The controller code:

public list<SelectOption> getVersionList(string pProductSeperatebyAssets) {

    list<Product2> products = new list<Product2>();
    list<Product_Version__c> versionsbyProd = new list<Product_Version__c>();
    for (WrapAsset asset : selectedWrapperList) {
        products.add(asset.asset.Product2);
    }
    versionsbyProd = [select Id, Name, Product__c from Product_Version__c where Name =:pProductSeperatebyAssets];

    system.debug('products: '+products);
    system.debug('versionsbyProd: '+versionsbyProd);

    List<SelectOption> versions = new List<SelectOption>();
    //versions.add(new SelectOption('', '-----None-----'));

    if (selectedWrapperList != null) {
        for (Product_Version__c v:versionsbyProd) {
            versions.add(new SelectOption(v.Id, v.Name));
        }
    }

    options = new list<SelectOption>(versions);
    system.debug('options: '+options);
    return versions;
}

public string choice {get; set;}

public string getChoiceVersion() {
    for (SelectOption so : getVersionList()){
        if (so.getLabel() == choice){
            return so.getLabel();
        }
    }
    return null;    
}

list<string> choiceVersionList = new list<string>();

public String getChoice() {
    return choice;
}  

public Id getVersion() {
    return this.version;
}

The visualPage code:

   <apex:pageBlockSection title="You Selected" columns="1">

        <apex:pageBlockTable value="{!selectedWrapperList}" var="asset" onRowClick="show(this);" >

            <apex:column headerValue="Asset Name" value="{!asset.asset.Name}" />
            <apex:column headerValue="Product Name" value="{!asset.asset.Product2.Name}" />
            <apex:column headerValue="Original Version" value="{!asset.asset.Product_Version_2__c}" />            
            <apex:column headerValue="Cloned Versions">
                <apex:actionRegion >
                    <apex:selectList size="1" multiselect="false">
                        <apex:selectOptions value="{!VersionList(asset.asset.Product2.Name)}"/>
                        <apex:actionFunction name="choice" action="{!getChoiceVersion}">
                          <apex:param value="{!getChoiceVersion}" name="degreeSelected" assignTo="{!choice}" />
                        </apex:actionFunction>  
                    </apex:selectList>
                </apex:actionRegion>
            </apex:column>
            <apex:column headerValue="Status" value="{!asset.asset.Status}" />                   
        </apex:pageBlockTable>
    </apex:pageBlockSection>   

Passing a parameter to the controller VersionList() function I am getting this error message: Compile Error for AssetProduct_ManualClone_ResultPage.page: Unknown function VersionList. Check spelling. at line None column None

Screenshot: display versions by each product name: enter image description here

1
  • Thanks. I got a solution using a SelectOption attribute list inside my WrapAsset class the easy way to pass specific list of versions to my Cloned Versions column. Jun 21, 2017 at 16:06

1 Answer 1

0

The solution for this problem is using a SelectOption attribute list inside my WrapAsset class the easy way to pass specific list of versions to my Cloned Versions headerValue.

public class WrapAsset {
    public Asset asset{get; set;}
    public String selVal {get; set;}
    public Boolean selected{get; set;}
    public list<SelectOption> selecteVersions{get; set;}
    public list<Product_Version__c> selections{get; set;}
    public WrapAsset(Asset pAsset) {
        this.asset = pAsset;
        this.selected = false;
        list<Product_Version__c> pv = [select id,Name from Product_Version__c where Product__c =: pAsset.Product2Id];
        list<SelectOption> selectVersions = new list<selectOption>();
        selectVersions.add(new SelectOption('', '--None--'));
        for (Product_Version__c v:pv) {
            selectVersions.add(new SelectOption(v.Id, v.Name));
        }
        this.selecteVersions = selectVersions;       
    }
}

then from the visualforce page call the selecteVersions get method:

<apex:column headerValue="Cloned Versions">
   <apex:selectList id="Positions" value="{!POS}" size="1">
       <apex:selectOptions value="{!asset.selecteVersions}"/>
   </apex:selectList>
</apex:column>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .