You need to sign in to do that
Don't have an account?
SFBlueFish
Adding Columns to Datatable dynamically
Hai friends,
Can you any body help me to add Columns to Datatable on Vfpage Dynamically.I have to display all records in Data table on vfpage. we can add rows dynamically to datatable,but i need to add columns to datatable.Please help me in this scenario.
Thank u,
Haribabu
For this you have to use dynamic binding
Let me give you structure , you can use it as per your req
mapHeader : It is the map that has Field API Name as Key and Hear for table column for this field
listItems : List of Items that you want to show in table
mapFieldToShow : Map has Field API Name As Key and Field Api name as Value also, both key and value are field API name
Use this will definitly solve your issue. I have used it
I just created a example :
Controller :
VFP
Give no of colums 1, 2 or 3 and refresh table.
Hai Sharma,
I too working opn same scenario, Can you please provide complete code for that, i will thankful to u sharma,please
Thanks in Advance
Elephant
Shashikant,
Thanks for posting this. You said you have used it. Can you please help me? I can display columns, but I cannot get column header to work, it is always blank.
below is snippet of my VF page
I tried with<apex:variable>, <apex:facet>, hard coded "TEST" too, but nothing seems to work. <inputField> works fine though.
I have spent almost 2 days in getting headerValue populated dynamically, now I give up.
Thank you for your time.
regards
ISVForce Partner
Hi,
This is what i am using for dynamic columns.
The column header will display if and only if you have atleast 1 record.
<apex:pageBlocktable value="{!Internship}" var="intern">
<apex:column >
<apex:facet name="header">
<apex:outputText value="Internship Name"/>
</apex:facet>
<apex:outputLink value="/{!intern.Id}">{! HTMLENCODE(intern.Name)}</apex:outputLink>
<apex:repeat var="f" value="{!$ObjectType.CustomObject__c.FieldSets.FIELDSETNAME}">
<apex:column value="{!intern[f]}"/>
</apex:repeat>
</apex:pageBlocktable>