1

I have a map called configMap. it is of type Map<String, Map<String, List<A__c>>> where it implies like Map<Obj, Map<Rec, List<A__c>>>. Just for understanding I have put obj and rec here.

I need to show the data in a vf page in below format.

**Obj 1**

   **Rec 1**

   Table shows List<A__c> data for Rec 1

   **Rec 2**
   Table shows List<A__c> data for Rec 2


**Obj 2**

   **Rec 1**
   Table shows `List<A__c>` data for Rec 1

To achieve this I am trying below approach that fails to print the data.

       <apex:repeat value="{!SetofObjectNames}" var="obj">
        {!configMap[obj]}
         <apex:repeat value="{!SetofRecordTypes}" var="rec"> 
          <apex:column value="{!configMap[obj][rec]}"/>
         </apex:repeat>
       </apex:repeat>
    </apex:pageBlockTable>   

It gives no error. Simply prints ID value for the records of that List.

Can someone please help me here?

  • If you want to display name for instance, you should do <apex:column value="{!configMap[obj][rec].Name}"/> . – N.. Jun 27 '18 at 11:23
2

Hopefully this approach might work for you.

Prepare the map and list as follows:

Map<String, Map<String, List<A__c>>> objectMap {get;set:}

//it will hold the keys like Obj1, Obj2
public List<String> lstObject {get;set;}
lstObject = objectMap.keySet();

//it will hold Rec1 of Obj1, Rec2 of Obj1
public List<String> innerMapKeys {get;set;}

public Map<String, List<A__c>> innerMap = new Map<String, List<A__c>>();

for(String : lstObject)
{
    innerMap = objectMap.get[str];
}
innerMapKeys = innerMap.keySet();

Visualforce

<apex:repeat value="{!lstObject}" var="obj">
    {!obj}
     <apex:repeat value="{!innerMapKeys}" var="rec"> 
        {!rec}
        <apex:pageBlockTable value="{!innerMap[rec]}" var="innerRec">
            <apex:column value="{!innerRec.Field__c"/>
        </apex:pageBlockTable>
     </apex:repeat>
</apex:repeat>

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.