You need to sign in to do that
Don't have an account?
Kristen Aldrich 14
If field in Visualforce pageBlockTable is empty, I can't edit it to add data.
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?
<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> </apex:page>
All Answers
We never use <apex:pageBlocktable> with unique values and that is your problem.
This trick was used to prevent the display of empty field probably but that also prevents the input of their values for inline editing.
<apex:pageBlocktable value="{!Opportunity.Meal_Date_1__c}" var="Meal_Date_1__c"><apex:pageBlockTable value="{!Opportunity.Meal_Date_2__c}"var="Meal_Date_2__c">
<apex:pageBlockTable value="{!Opportunity.Meal_Date_3__c}" var="Meal_Date_3__c"><apex:pageBlockTable value="{!Opportunity.Meal_Date_4__c}"var="Meal_Date_4__c">
If you want a table format with unique values, you can just use the HTML and CSS tags.
https://www.lightningdesignsystem.com/components/data-tables/