5

Question

I'm trying out the apex:inlineEditSupport for the first time and am having some trouble getting the showOnEdit and hideOnEdit attributes to work. My codes is based on the example from the inlineEditSupport docs, but the when I double click a field to start inline editing the back to record button is NOT hidden, and the save/cancel buttons are NOT shown.

For comparison when you inline edit a field on the standard detail page the initial detail buttons are hidden and replaced with show/cancel buttons. My goal is to emulate the standard behavior with my page.

Code

<apex:pageBlock>
    <apex:pageBlockButtons >
        <apex:commandButton action="{!save}" id="saveButton" value="Save" rendered="false"/>
        <apex:commandButton action="{!cancel}" id="cancelButton" value="Cancel" rendered="false"/>
        <apex:commandButton action="{!cancel}" value="Back to Record" id="backButton"/>
    </apex:pageBlockButtons>
    <apex:pageBlockSection columns="1">
        <apex:outputField value="{!account.name}">
            <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" 
                hideOnEdit="backButton"
                event="ondblclick"/>
        </apex:outputField>
    </apex:pageBlockSection>
</apex:pageBlock>
  • Did you make sure to turn on Inline Editing under Name|Setup|App Setup|Customize|User Interface? – Adam Apr 18 '13 at 0:32
  • It's on. The inline edit works just fine, just not the button show/hide functions. – Ralph Callaway Apr 18 '13 at 0:36
  • Hi, Ralf. I have the same problem, that the Cancel button appears only once. No workarount yet :( salesforce.stackexchange.com/questions/10537/… – Sergej Utko Apr 18 '13 at 6:40
6

The Save and Cancel buttons are not displayed or hidden because they are not sent to the browser, as you have used rendered="false" on them. If you want to display them hidden initially but still have the ability to display them when needed, you need to use the "style" attribute.

<apex:pageBlock >
    <apex:pageBlockButtons >
        <apex:commandButton action="{!save}" id="saveButton" value="Save" style="display:none"/>
        <apex:commandButton action="{!cancel}" id="cancelButton" value="Cancel" style="display:none"/>
        <apex:commandButton action="{!cancel}" value="Back to Record" id="backButton"/>
    </apex:pageBlockButtons>
    <apex:pageBlockSection columns="1">
        <apex:outputField value="{!account.name}">
            <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" 
                hideOnEdit="backButton"
                event="ondblclick"/>
        </apex:outputField>
    </apex:pageBlockSection>
</apex:pageBlock>

Regarding the use of style='display:none' above. I think having the buttons visible initially is OK (as per the Salesforce docs) so long as they perform something appropriate for the state of the page. Using 'style' then, is just that, a UI preference, if you prefer them not to be shown initially.

  • I'm using the same approach, but i have one big issue that the Cancel button appears only once: salesforce.stackexchange.com/questions/10537/… – Sergej Utko Apr 18 '13 at 6:42
  • @mast0r I've just put an answer on the question for you. – Andrew Fawcett Apr 18 '13 at 7:32
  • Interesting, that seems to run completely counter to how the other show/hide stuff works with Visualforce, i.e. the documentation should state that the 'showOnEdit' buttons should have their style output set to 'display: none' to work correctly. That's what you're suggesting correct? – Ralph Callaway Apr 20 '13 at 16:43
  • The documentation also mentions a reset JavaScript function which I have been unable to find reference to. I've used the documentation feedback option to ask about this. I think having the buttons visible initially is OK so long as they perform something appropriate for the state of the page. Using 'style' then, is just that, a UI preference. – Andrew Fawcett Apr 21 '13 at 8:06
  • @AndrewFawcett so to confirm, in your experience both the showOnEdit / hideOnEdit attributes work by setting/removing the style display: none attribute for the button with the matching ids? If so, could you update the answer and I'll accept it? – Ralph Callaway Apr 23 '13 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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