0

I'm creating a Visualforce pageBlockTable for some custom fields on an Opportunity record. It works great when data is entered upon creation of an Opportunity record, but any blank fields in the pageBlockTable are inaccessible so I can't create the opportunity and go back to add data into those fields. How can I make blank fields editable in the table? Pasting my code below.

<apex:page standardController="Opportunity">
<apex:form >
    <apex:pageBlock mode="inlineEdit">
         <apex:pageBlockButtons >
            <apex:commandButton action="{!edit}" id="editButton" value="Edit"/>
            <apex:commandButton action="{!save}" id="saveButton" value="Save"/>
            <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
            </apex:pageBlockButtons>
        <apex:pageBlocktable value="{!Opportunity.Meal_Date_1__c}" var="Meal_Date_1__c">
              <apex:column headerValue="Day 1">
                <apex:inputfield value="{!Opportunity.Meal_Date_1__c}"/>
                <apex:outputField value="{!Opportunity.Meal_Date_1__c}"/>
            </apex:column>
            <apex:column headerValue="Breakfast">    
                <apex:inputField value="{!Opportunity.Breakfast_1__c}" />
            </apex:column>
            <apex:column headerValue="Lunch">
                <apex:inputField value="{!Opportunity.Lunch_1__c}" />
            </apex:column>
            <apex:column headerValue="Dinner">
                <apex:inputField value="{!Opportunity.Dinner_1__c}" />
            </apex:column>
            <apex:column headerValue="Time">
                <apex:inputField value="{!Opportunity.Meal_Time_1__c}" />
            </apex:column>
            </apex:pageBlockTable>
            <apex:pageBlockTable value="{!Opportunity.Meal_Date_2__c}" var="Meal_Date_2__c">
            <apex:column headerValue="Day 2">
                <apex:inputField value="{!Opportunity.Meal_Date_2__c}" />
            </apex:column>
            <apex:column headerValue="Breakfast">    
                <apex:inputField value="{!Opportunity.Breakfast_2__c}" />
            </apex:column>
            <apex:column headerValue="Lunch">
                <apex:inputField value="{!Opportunity.Lunch_2__c}" />
            </apex:column>
            <apex:column headerValue="Dinner">
                <apex:inputField value="{!Opportunity.Dinner_2__c}" />
            </apex:column>
            <apex:column headerValue="Time">
                <apex:inputField value="{!Opportunity.Meal_Time_2__c}" />
            </apex:column>
            <apex:inlineEditSupport event="ondblClick" 
                    showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
            </apex:pageBlockTable>
            <apex:pageBlockTable value="{!Opportunity.Meal_Date_3__c}" var="Meal_Date_3__c">
            <apex:column headerValue="Day 3">
                <apex:inputField value="{!Opportunity.Meal_Date_3__c}" />
            </apex:column>
            <apex:column headerValue="Breakfast">    
                <apex:inputField value="{!Opportunity.Breakfast_3__c}" />
            </apex:column>
            <apex:column headerValue="Lunch">
                <apex:inputField value="{!Opportunity.Lunch_3__c}" />
            </apex:column>
            <apex:column headerValue="Dinner">
                <apex:inputField value="{!Opportunity.Dinner_3__c}" />
            </apex:column>
            <apex:column headerValue="Time">
                <apex:inputField value="{!Opportunity.Meal_Time_3__c}" />
            </apex:column>
            <apex:inlineEditSupport event="ondblClick" 
                    showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
            </apex:pageBlockTable>
            <apex:pageBlockTable value="{!Opportunity.Meal_Date_4__c}" var="Meal_Date_4__c">
            <apex:column headerValue="Day 4">
                <apex:inputField value="{!Opportunity.Meal_Date_4__c}" />
            </apex:column>
            <apex:column headerValue="Breakfast">    
                <apex:inputField value="{!Opportunity.Breakfast_4__c}" />
            </apex:column>
            <apex:column headerValue="Lunch">
                <apex:inputField value="{!Opportunity.Lunch_4__c}" />
            </apex:column>
            <apex:column headerValue="Dinner">
                <apex:inputField value="{!Opportunity.Dinner_4__c}" />
            </apex:column>
            <apex:column headerValue="Time">
                <apex:inputField value="{!Opportunity.Meal_Time_4__c}" />
            </apex:column>
            <apex:inlineEditSupport event="ondblClick" 
                    showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
            </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>

1 Answer 1

0

apex:pageBlockTable is not meant to be used this way; it is designed to show a list of values (think of a table). You should instead be using apex:pageBlockSection or apex:panelGrid to define sections of the apex:pageBlock that look as you expect. You can specify 5 column layouts in apex:pageBlockSection, but they may appear distorted. You could also use apex:slds for more control using SLDS styling.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .