function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PrabhaPrabha 

Maps in visualforce

Hi

 

Is the following possible in pageblock table?

 

I have a map structure: map<string, list<string>> ,

the values could be,

for example:

key: fruits:

values: orange, apple, grape

key: Vehicle:

values: car, motorbike, trolley, lorry, truck

key: shape:

values: round, square.

 

Now I want to show that in a pagblock table where keys as column headers and values as column values! 

 

I was only able to get that with map<string, string>. 

 

 
       <apex:pageBlockTable value="{!a1}" var="ms">
           <apex:repeat value="{!a1}" var="r"> 
                   <apex:column headerValue="{!r}"> 
                       <apex:repeat value="{!a1[r]}" var="r1"> 
                         {!r1}
                       </apex:repeat>
                   </apex:column>
           </apex:repeat>
       </apex:pageBlockTable>

 Please enlighten me on this. 

Can it be done as the way I want it to be?

 

 

Prabhan

Best Answer chosen by Prabha
PrabhaPrabha

Hi

The same is possible with a break tag in repeat.

 

like the following.

<apex:pageBlockTable value="{!a1}" var="ms">
           <apex:repeat value="{!a1}" var="r"> 
                   <apex:column headerValue="{!r}"> 
                       <apex:repeat value="{!a1[r]}" var="r1"> 
                         {!r1}<br/>
                       </apex:repeat>
                   </apex:column>
           </apex:repeat>
       </apex:pageBlockTable>

But I want to populate 'null' or '-' for the empty values, highlight the row when we move the mouse over, like in pageblock. Can you please suggest me some solution for that.

 

Prabhan

All Answers

Puja_mfsiPuja_mfsi

Hi,

U can use html table to get the result.

I'll give u an example how to use html table with Map:

 

<apex:pageBlock>
     <table >
          <tr>
              <apex:repeat value="{!mapObj}" var="ms">  <!--- mapObj uor map <String,List<String>> -->
                  <td style="padding-left:5px;">

                        <span style="font-weight: bold;padding-left: 5px;">{!ms} </span>
                         <table>
                                <apex:repeat value="{!mapObj[ms]}" var="r1"> <!-- Second repeat is here.-->
                                        <tr>
                                             <td>
                                                      {!r1}
                                              </td>
                                         </tr>
                                  </apex:repeat>
                             </table>
                      </td>
                </apex:repeat>
            </tr>
       </table>
</apex:pageBlock>

 

Please let me know if u have any problem on same and if this post helps u plz give KUDOS by click on star at left.

PrabhaPrabha

Hi

The same is possible with a break tag in repeat.

 

like the following.

<apex:pageBlockTable value="{!a1}" var="ms">
           <apex:repeat value="{!a1}" var="r"> 
                   <apex:column headerValue="{!r}"> 
                       <apex:repeat value="{!a1[r]}" var="r1"> 
                         {!r1}<br/>
                       </apex:repeat>
                   </apex:column>
           </apex:repeat>
       </apex:pageBlockTable>

But I want to populate 'null' or '-' for the empty values, highlight the row when we move the mouse over, like in pageblock. Can you please suggest me some solution for that.

 

Prabhan

This was selected as the best answer