0

I have a aggregated class as below snippet below

public list<AggregateResult> getLastTopInfos () {
    return [SELECT Account__r.Name aaa, SUM(value__c) bbb, Account__r.Strategy__c ccc
            FROM Info__c 
            WHERE Account__c = :ApexPages.currentPage().getParameters().get('id') AND Value__c > 0
            Group By Account__r.Name, Account__r.Strategy__c
            Order by SUM(value__c)  DESC
            LIMIT 10
    ];
}

<apex:pageBlock title="InfosbyAccount" rendered="{!IF(LastTopInfos.size>0,true,false)}" >
    <apex:pageBlockTable value="{!LastTopInfos}" var="h" border="2">
        <apex:column value="{!h['aaa']}"/>
        <apex:column value="{!h['ccc']}"/>
        <apex:column value="{!h['bbb']}"/>

    </apex:pageBlockTable>
</apex:pageBlock>

Its displayed as below without any column header

Account1 strategy1 Value1
Account2 strategy2 Value2
and so on..................
Account10 stratgey10 Value10

How can I include the column labels and have the VF page rendered as below

AccountName StrategyName Value
Account1 strategy1 Value1
Account2 strategy2 Value2
and so on..................
Account10 stratgey10 Value10

1

You could use apex:facet inside apex:column to display header as follows:

<apex:pageBlock title="InfosbyAccount" rendered="{!(LastTopInfos.size>0)}" >
    <apex:pageBlockTable value="{!LastTopInfos}" var="h" border="2">
        <apex:column >
            <apex:facet name="header">AccountName </apex:facet>
                    {!h['aaa']}
        </apex:column>
        <apex:column >
            <apex:facet name="header">StrategyName  </apex:facet>
                    {!h['ccc']}
        </apex:column>
        <apex:column >
            <apex:facet name="header">Value </apex:facet>
                    {!h['bbb']}
        </apex:column>

    </apex:pageBlockTable>
</apex:pageBlock>

Refer apex:facet

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.