I have a wrapper class with map inside, which i need to display in a visualforce page in a page block table with column headers. Also i wanted to build an export feature on this table so i should be rendering data in the table in Page Block Table. But i'm facing a challenge with column header in page block table , which is currently not working with map ( i used repeat component). Can anyone suggest me an alternative or a fix for this issue.
I'm attaching the wrapper class and the page block table for a reference.
Wrapper Class:
public class historyWrapper
{
public History__c hs{get;set;}
public Map<String,String> keyValueMap{get;set;}
historyWrapper(History__c h)
{
hs = h;
keyValueMap = new map<String,String>();
for(String s: h.Stage_String__c.Split(';'))
{
keyValueMap.put(s.split(':')[0],s.split(':')[1]);
}
}
}
Visual force Page:
<apex:pageBlockTable var="hs" value="{!historyWrp}">
<apex:repeat var="key" value="{!hs.keyValueMap}">
<apex:column >
<apex:facet name="header">{!key}</apex:facet>
{!hs.keyValueMap[key]}
</apex:column>
</apex:repeat>
</apex:pageBlockTable>
The variable historyWrp is a list of wrapper class historyWrapper. I hope it will avoid all confusion.
What i'm trying here is every wrapper record will have list of key value pairs(like new:10;Working:20; etc..) that i would need to display as column in visualforce page with value. The final page will be like New|Working as column header and 10|20 as values beneath it.
value
property ofapex:repeat
intovalue="{!keyValueMap}"
and check