9

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>
  • 1
    did you find any solution for this ? I recently started getting error for the reset function "resetInlineEdit". "resetInlineEdit not defined" – Avidev9 Oct 2 '13 at 20:43
  • @Avidev9 nope, no solution yet :( – Sergej Utko Oct 3 '13 at 8:23
4

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.

  • 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. – Sergej Utko Apr 18 '13 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 May 8 '14 at 20:43
1

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()"/>

  • 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. – Sergej Utko Apr 15 '13 at 8:04

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.