10

I have a problem with apex:inlineEditSupport function. I have an apex:outputField with inline edit support. When i edit this field for the first time (double click), the "Cancel" button appears. After I click on "Cancel" button, this button disappears. But if I edit the field again - the "Cancel" button is no longer displayed. What is wrong with my code?

The Controller:

public with sharing class TestInlineEdit{
    public Account acc { get; set; }
    public TestInlineEdit(){
        acc = [Select id, Name, Street__c 
               From Account 
               Where Street__c != null 
               Limit 1];
    }
    public PageReference simpleAction(){
        return null;
    }
}

The visualforce page:

<apex:page controller="TestInlineEdit">
    <apex:form>
        <apex:pageBlock id="myBlock">
            <apex:pageBlockButtons >
                <apex:commandButton reRender="myBlock" id="cancelButton"  
                                    action="{!simpleAction}"
                                    value="Cancel" style="display:none"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection>
                <apex:outputField value="{!acc.Street__c}">
                    <apex:inlineEditSupport showOnEdit="cancelButton"
                                            event="ondblclick" />
                </apex:outputField>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
2
  • 1
    did you find any solution for this ? I recently started getting error for the reset function "resetInlineEdit". "resetInlineEdit not defined"
    – Avidev9
    Commented Oct 2, 2013 at 20:43
  • @Avidev9 nope, no solution yet :( Commented Oct 3, 2013 at 8:23

2 Answers 2

5

It appears to be the use of rerender on the apex:commandButton, removing this resolves the issue (but does of course refresh the whole page, which maybe what you want anyway?). It maybe that the HTML Id for the button is being regenerated by the rerender and the logic in the page driving the inline editing support is still using the old HTML id, its worth raising this as a support case.

2
  • Thank you for the arswer Andrew. I don't want to reload the page, because some inputs on the page are gone then. It is a custom Visualforce Page, i just want to create a Cancel button like on the standard layout page. That button don't reloads the whole page, just fires sfdcPage.revert();? I've tried to use onclick="return false;" instead of reRender="none", but without success. Commented Apr 18, 2013 at 8:29
  • I ran into @mast0r 's issue today and can confirm that it resolved itself for me by removing the rerender on the commandbutton, instead, taking the default and rerendering the whole page. Thanks.
    – cropredy
    Commented May 8, 2014 at 20:43
2

Normally, a Cancel button action would be to take the user off the page so you wouldn't be rerendering the same page.

As your simpleAction controller method just returns null, I would surmise that the commandButton style="display:none" is suppressing the Cancel button. Have you tried the resetInlineEdit() function?

On my VF pages, I use this:

<apex:commandButton id="cancel" value="Cancel" action="{!cancel}" style="display: none;" onclick="resetInlineEdit()"/>

1
  • Thank you for the answer! Yes, i have tried the resetFunction, but it does not work too. What i generally want is the behavior as on the standard layout page if you inline edit one field. Commented Apr 15, 2013 at 8:04

You must log in to answer this question.

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