+ Start a Discussion
Semira@gmail.comSemira@gmail.com 

Column header disappear when using repeat in PageblockTable

Hi all, 

I'm trying to repeat bunch of rows in a pageblocktable. However I don't want my header to repeat, just the values. Right now, my headers doesn't show up at all!

How do I resolve this? 
 
<apex:outputPanel id="table">
            <apex:pageBlockTable value="{!LineItems}" var="item" columns="3">  

            <apex:repeat value="{!item}" var="m">              
                <apex:column ><apex:facet name="header">Materials</apex:facet>
                    <apex:inputfield value="{!m.Description__c}"/>
                </apex:column>     
                <apex:column ><apex:facet name="header">Ship</apex:facet>
                    <apex:inputfield value="{!m.Quantity_Shipped__c}"/>
                </apex:column>
            </apex:repeat>
            </apex:pageBlockTable>
</apex:outputPanel>


 
Best Answer chosen by Semira@gmail.com
Suneel#8Suneel#8

I guess repeat tag is not required inside PageBlockTable component.Please check that
        <apex:pageBlockTable value="{!accounts}" var="a" columns="2">
            <apex:column >
                <apex:facet name="header">Account Name</apex:facet>
                <apex:inputField value="{!a.name}" />
            </apex:column>
            <apex:column >
                <apex:facet name="header">Account Status</apex:facet>
                <apex:inputField value="{!a.Active__c}" />
            </apex:column>            
        </apex:pageBlockTable>

All Answers

Aditya MohanAditya Mohan
Hi Semira,
Instead of using <apex:pageBlockTable>, you can use <apex:dataTable>. Its because <apex:facet> component is supported under only specific parent components like <apex:dataTable>.  So it can be like:
 
<apex:outputPanel id="table">
            <apex:dataTable value="{!LineItems}" var="item" columns="3">  

            <apex:repeat value="{!item}" var="m">              
                <apex:column ><apex:facet name="header">Materials</apex:facet>
                    <apex:inputfield value="{!m.Description__c}"/>
                </apex:column>     
                <apex:column ><apex:facet name="header">Ship</apex:facet>
                    <apex:inputfield value="{!m.Quantity_Shipped__c}"/>
                </apex:column>
            </apex:repeat>
            </apex:dataTable>
</apex:outputPanel>

 
Suneel#8Suneel#8

I guess repeat tag is not required inside PageBlockTable component.Please check that
        <apex:pageBlockTable value="{!accounts}" var="a" columns="2">
            <apex:column >
                <apex:facet name="header">Account Name</apex:facet>
                <apex:inputField value="{!a.name}" />
            </apex:column>
            <apex:column >
                <apex:facet name="header">Account Status</apex:facet>
                <apex:inputField value="{!a.Active__c}" />
            </apex:column>            
        </apex:pageBlockTable>
This was selected as the best answer