Sample Code
VisualForce Page
<apex:page standardController="Account" recordSetVar="account" extensions="MapkeyExample">
<apex:pageBlock>
<apex:pageBlockTable value="{!Account}" var="acc">
<apex:column headerValue="Account Name">
<apex:outputLabel value="{!acc.name}"></apex:outputLabel>
<apex:pageBlockTable rendered="{!IF(CONTAINS(ChkMapKey,acc.name),true,false)}" value="{!accMap[acc.name]}" var="ss">\
<apex:column headerValue="Child Map value" value="{!ss}" />
</Apex:pageBlockTable>
</apex:column>
</Apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Apex Class
public class MapkeyExample
{
public string ChkMapKey{get;set;}
public map < string, string > accMap{get;set;}
public MapkeyExample(ApexPages.StandardSetController controller)
{
accMap = new map < string, string >{'test' => '1', 'test account' => '2', 'C' => '3', 'D' => '4', 'E' => '5', 'F' => '6'};
ChkMapKey = string.valueof(accMap.keyset()).replace('{', '').replace('{', '');
}
}
In above code i have created following things:
1. Test Account
2. ChkMapKey String propeerty
3. accMap Map.
VisualForce Page
<apex:page standardController="Account" recordSetVar="account" extensions="MapkeyExample">
<apex:pageBlock>
<apex:pageBlockTable value="{!Account}" var="acc">
<apex:column headerValue="Account Name">
<apex:outputLabel value="{!acc.name}"></apex:outputLabel>
<apex:pageBlockTable rendered="{!IF(CONTAINS(ChkMapKey,acc.name),true,false)}" value="{!accMap[acc.name]}" var="ss">\
<apex:column headerValue="Child Map value" value="{!ss}" />
</Apex:pageBlockTable>
</apex:column>
</Apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Apex Class
public class MapkeyExample
{
public string ChkMapKey{get;set;}
public map < string, string > accMap{get;set;}
public MapkeyExample(ApexPages.StandardSetController controller)
{
accMap = new map < string, string >{'test' => '1', 'test account' => '2', 'C' => '3', 'D' => '4', 'E' => '5', 'F' => '6'};
ChkMapKey = string.valueof(accMap.keyset()).replace('{', '').replace('{', '');
}
}
In above code i have created following things:
1. Test Account
2. ChkMapKey String propeerty
3. accMap Map.
No comments:
Post a Comment