0

I am having pick list field having all existing objects, if i select any object i need to display the particular selected object fileds in the below section with checkbox before the field label as shown in the fiqure. Any one please send me the code regarding this.

Thanks in advance....

enter image description here

          <apex:pageBlockSectionItem >
              <apex:outputlabel value="Object Names :"/> 
                  <apex:actionRegion >      
                       <apex:selectList value="{!selectedObject}" size="1">
                                <apex:selectOptions value="{!ObjectNames}"/>
                                <apex:actionSupport event="onchange" rerender="myFields"/>
                        </apex:selectList>
                 </apex:actionRegion>                         
          </apex:pageBlockSectionItem>

          <apex:pageBlockSectionItem >
                  <apex:outputlabel value="Field Names :"/>   
                  <apex:outputPanel id="myFields">   
                    <apex:actionRegion >  
                       <apex:selectList value="{!selectedField}" size="1">
                            <apex:selectOptions value="{!ObjectFields}"/>
                        </apex:selectList>
                    </apex:actionRegion>      
                 </apex:outputPanel>
          </apex:pageBlockSectionItem>

      </apex:pageBlockSection>
  </apex:pageBlock>

public class mappingController { public Map schemaMap = Schema.getGlobalDescribe();

public String selectedObject {get; set;}

public String selectedField {get; set;}

Public mappingController()
{   
    selectedObject = 'account';
}

public List<SelectOption> getObjectNames() 
{
    List<SelectOption> objNames = new List<SelectOption>();
    List<String> entities = new List<String>(schemaMap.keySet());
    entities.sort();
    for(String name : entities)
    {
        objNames.add(new SelectOption(name,name));
    }
    return objNames;
 }

 public List<SelectOption> getObjectFields() 
 {
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
        Map<String, Schema.SObjectField> fieldMap = ObjectSchema.getDescribe().fields.getMap();
        List<SelectOption> fieldNames = new List<SelectOption>();
        for (String fieldName: fieldMap.keySet()) 
        {  
            fieldNames.add(new SelectOption(fieldName,fieldName));
          //fieldMap.get(fieldName).getDescribe().getLabel();//It provides to get the object fields label.
        }
        return fieldNames;
  }       

}

Here i am getting only dependent picklist with all filed name, but i need checkbox before the field name as shown in the image

1
  • Can you please share what have you already tried? This community would be more than happy to assist you in solving a problem/issue that you are encountering with something that you have attempted rather than writing the entire piece of code for you. Apr 25, 2015 at 6:19

1 Answer 1

0

You need to use checkbox because you want to select multiple value at one time right?Why not just use Picklist(multi-select) field type.It serves the same features:the user can select multiple value in the list.Multi-Select Picklist Field Type

You must log in to answer this question.

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