Display data using Apex Maps in Visualforce Page - Salesforce Globe For You
Apex Code: DisplayMapController
public class DisplayMapController {
public Map<String,Account> mapAccount {get;set;}
public DisplayMapController() {
mapAccount = new Map<String,Account>();
for(Account objAccount:[Select id,name,type,description from Account]) {
mapAccount.put(objAccount.Id,objAccount);
}
}
}
Visualforce Page:DisplayMap
<apex:page controller="DisplayMapController">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection>
<apex:pageBlockTable value="{!mapAccount}" var="acc">
<apex:column value="{!mapAccount[acc].Name}"/>
<apex:column value="{!mapAccount[acc].Type}"/>
<apex:column value="{!mapAccount[acc].Description}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Output:
Apex Code: DisplayMapController
public class DisplayMapController {
public Map<String,Account> mapAccount {get;set;}
public DisplayMapController() {
mapAccount = new Map<String,Account>();
for(Account objAccount:[Select id,name,type,description from Account]) {
mapAccount.put(objAccount.Id,objAccount);
}
}
}
Visualforce Page:DisplayMap
<apex:page controller="DisplayMapController">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection>
<apex:pageBlockTable value="{!mapAccount}" var="acc">
<apex:column value="{!mapAccount[acc].Name}"/>
<apex:column value="{!mapAccount[acc].Type}"/>
<apex:column value="{!mapAccount[acc].Description}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Output:
No comments:
Post a Comment