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
dev401hasdev401has 

Caption on PageBlock Table

I want to add Caption above PageBlockTable.

 

Now the situation is that I am having List of List coming from extension. On my VF page I am using repeater and in that I am using Pageblock table. So repeater repeats pageblock table as many times there are lists in the main list and then pageblock table displays data of those lists. So how to add caption over each Pageblock Table.

 

I tried using <apex:facet name="caption"> but of no use. I have a list of values so cannot get caption.

 

I hope I have explained my criteria clearly. Any solution on this??

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

So if I understand correctly, one of the values in each of the lists is the caption?

 

If that is the case, I think you will have to handle this controller side, as I don't believe there's a way to extract a single value from a list on the page.

 

The other option is to make change your main list so that each element is an instance of a custom class.  That custom class contains a single field for the caption and a list of the fields that should be displayed in the table.  Then as you iterate the list, you can output the caption and then use the associated list as the value for the pageblocktable.

All Answers

bob_buzzardbob_buzzard

In your description, you say that you can't use the caption facet because you have a list of values.  That being the case, how can you identify what you want to display as the caption for each table?

dev401hasdev401has

Sorry I was not exactly clear with my words. I can identify the caption as it is one of my value/field in the list and I am getting different lists on the base of that value only and then i am adding it in my main list.

 

Say there are two lists in main List. List A and List B. List A will have value a1 in each records and List two will have a2 in each records. I am seperating list on base of that only.

bob_buzzardbob_buzzard

So if I understand correctly, one of the values in each of the lists is the caption?

 

If that is the case, I think you will have to handle this controller side, as I don't believe there's a way to extract a single value from a list on the page.

 

The other option is to make change your main list so that each element is an instance of a custom class.  That custom class contains a single field for the caption and a list of the fields that should be displayed in the table.  Then as you iterate the list, you can output the caption and then use the associated list as the value for the pageblocktable.

This was selected as the best answer
dev401hasdev401has

Thanks Bob.

 

I created custom class and was able to achieve what i wanted.