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
Vigneshwaran GVigneshwaran G 

InlineEditSupport not showing buttons if the outputField is not rendered initially

Am trying to get to know about the InlineEditSupport from the Saleforce documents and used the code provided there with some modifications.

This is my Visualforce page:

<apex:page standardController="Contact" extensions="inlineController">
    <apex:form >
        <apex:pageBlock id="pb">
            <apex:pageBlockButtons >               
                <apex:commandButton id="saveButton" value="Save" reRender="pb" style="display:none;"/>
                <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel" style="display:none;"/>
                <apex:commandButton value="Refresh" reRender="pb" action="{!refresh}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection >
                <apex:outputField value="{!contact.lastname}" rendered="{!boolRender}">
                    <apex:inlineEditSupport showOnEdit="saveButton, cancelButton"
                        event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
                </apex:outputField>
                <apex:outputField value="{!contact.accountId}"/>
                <apex:outputField value="{!contact.phone}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

This is my Controller i added to check a functionality:

public with sharing class inlineController {
    public boolean boolRender {get; set;}
   
    public inlineController(ApexPages.StandardController controller) {
        boolRender = true;
    }
    public void refresh(){
        if(boolRender == false)
            boolRender = true;
        else
            boolRender = false;
    }
}

I used style="display:none;" in both save and cancel buttons because i want them to be invisible at start. Once i double click on the Contact Lastname these two buttons will show up.

Now comes the tricky part in which am facing issues. I used rendered="{!boolRendered}" in the Contact Lastname Outputfield, so that it will be rendered based on the condition which i set in Controller.

In constructor i set it to true and everything works fine. If is set it to false, initially the field will not be shown, on click of refresh it will be shown, but if i double click on the Contact Lastname field the two buttons not showing up.

Cause:
I think the cause for this behaviour is that the field in which inlineEditSupport is binded is not rendred initially and then the binding between the buttons are lost.

Work Around: 
I can remove style="display:none;" from both buttons, but it will always be visible which is not like standard salesforce inlilne edit.

Can anyone explain me why this is happening and can provide me any work around?
gautam_singhgautam_singh
Hi Vignes,

Try removing the reRender Attribute from the 'Refresh' Command button when you have boolRender = False in Constructor. The buttons will show on double click of Name Field.

Important :

Click on the Star Icon aside if this post provides you with useful information and if this is what you where looking for then please mark it as a solution for others benefits.

Thank You