0

I have hotel object where custom pick-list field days I need to get days field values(Sunday to Saturday) in table header by using vf page dynamically. I wrote an apex class where i get all value but i am unable to implement in vf page how to do it?

Apex class:

public with sharing class dayextension {
    public List<string> stages {get;set;}
    public List<string> types {get;set;}
    Public Hotel__c hotel {get;set;}
    public boolean displayPopup {get; set;}    
    public dayextension (ApexPages.StandardController controller) {
        stages = new list<string>();
        types = new list<string>();
        Schema.DescribeFieldResult fieldResult = Hotel__c.Days__c.getDescribe();
        System.debug(fieldResult);
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues(); 
        system.debug('--ple -->>'+ple);              
        for( Schema.PicklistEntry f : ple){
           stages.add(f.getLabel());
        }
        hotel = [select id,Days__c from Hotel__c where id=: controller.getRecord().id];
        system.debug('--hotel-->>'+hotel);
    }
}

Vf Page:

<apex:page standardController="Hotel__c" extensions="dayextension">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!stages}" var="dbItem">
            <apex:repeat value="{!stages}">
                <apex:column value="{!hotel.Days__c}"/> 

            </apex:repeat>    
            </apex:pageBlockTable> 
        </apex:pageBlock>
    </apex:form>
</apex:page>
2

Not exactly sure what you're trying to do but try this with your repeat block:

        <apex:repeat value="{!stages}" var="stage">
            <apex:column value="{!stage}"/> 
        </apex:repeat>   

That should print a column for each picklist value.

| improve this answer | |

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.