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
Mike Lee 12Mike Lee 12 

Visualforce inline edit - duplicating dynamic button functionality of <apex:detail inlineEdit="True">

Hello,

During some testing of Visualforce using inline edit I've found that when using <apex:detail inlineEdit="True"> double clicking on a field and making a change causes the displayed buttons to dynamically change. When using the Account standard controller the buttons change from Edit, Delete, Sharing, Include Offline to Save,Cancel.

I'd like to do have this same functionality on a page that doesn't use <apex:detail>. I don't need to display every field on this page. Currently the page I've created does support inline editing and changes do get saved correctly. However the page always display the Edit, Save, Cancel buttons and doesn't dynamically change like it does within <apex:detail>.

Does anyone know if replicating the button behavior of <apex: detail inlineEdit="True"> is possible?

Thanks,

Mike
Best Answer chosen by Mike Lee 12
Deepak GulianDeepak Gulian
<apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel" immediate="true"/>
Add immediate="true" like above

All Answers

Mike Lee 12Mike Lee 12
Thanks for the link Deepark! I placed that code into the page and got the buttons working like I wanted to. 

One issue though (this happens with both the example code and the page I'm working on). If you double click on a field, change the value, click off of the field, and then click on Cancel the page refreshes and no change is made to the record. However the field I double clicked on previously still shows the changed value. Say I changed the address field from 124 Connor Street to 999 Connor Street and hit cancel the refreshed page would still show 999 Connor Street even though the actual record still shows 124 Connor Street.

Any ideas as to how I could have the address updated with the actual value stored in the database?

Thanks,

Mike
Deepak GulianDeepak Gulian
<apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel" immediate="true"/>
Add immediate="true" like above
This was selected as the best answer
Mike Lee 12Mike Lee 12
That did the trick. Thanks Deepak.

Side question if you have a sec -resetInlineEdit(). Any documentation on this piece of Javascript?
Deepak GulianDeepak Gulian
I'm sorry about that sir , I really don't have any documentation on this piece of Javascript.