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
NewInternNewIntern 

Double-click instead of single click for custom SObject checkbox

I have the following Visualforce page in the Contacts page layout:

 

http://i.stack.imgur.com/QfpZV.png

 

 

A single click will toggle the checkbox selection ( as expected) and update the SObject field value. This is all good. However, I want to be able to change the checkbox value on a double-click, not on a single click. Something like how the same custom SObject checkbox behaves when otherwise used directly on the SF page layout (versus on a VF page) would also be nice:

  

http://i.stack.imgur.com/QW29E.png

 

Here is my VF page code for the SObject checkbox:

 

<apex:pageBlock id="theBlock">
<!-- first row -->
    <apex:pageBlockTable value="{!contact}" var="c"> 
         <apex:column headerValue="On Approved List" width="111">
            <apex:inputField value="{!c.EJF_On_Approved__c}"> 
                <apex:actionSupport event="onclick" reRender="theBlock" action="{!saveRecord}"/> 
            </apex:inputfield>
        </apex:column>

 

Suggested changes to the code if provided as complete code would be highly appreciated. Thanks!

Avidev9Avidev9

Tried inline edit support?

 

<apex:outputField value="{!c.EJF_On_Approved__c}"> 
                <apex:inlineEditSupport event="ondblclick" /> 
            </apex:outputfield>
NewInternNewIntern

Thank you for your response. 

 

I tried inline editing - the issue is I am not able to change the checkbox selection because <apex:outputField> renders the field read-only. I need to toggle the checkbox on the VF page display.

souvik9086souvik9086

Double-click on the SF page layout? I think you are talking about Inline edit?

NewInternNewIntern
Yes, inline editing on the VF page checkbox, which is seen in Contacts page layout. Right now I can edit it with a single click, I want users to be able to edit it only with a double-click
souvik9086souvik9086

Yes then why Avidev solution didn't worked?

 

Try adding this

<apex:outputField value="{!c.EJF_On_Approved__c}">
<apex:inlineEditSupport showOnEdit="saveButton" event="ondblclick"/>
</apex:outputField>

 

showOnEdit="saveButton" This is the id of the save button.

 

Like this

<apex:commandButton value="Save" id="saveButton" action="{!Yourmethod}"/>

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

 

 

NewInternNewIntern
I want the user selection of the checkbox to be remembered without a button click on save. Just a double-click to edit and done, checkbox saved. This is my exact requirement. And this is how standard checkbox fields are updated - there is no button click involved to save your selection.
souvik9086souvik9086

Then you have to some more workaround. You can call an apex method through actionsupport from within inline edit support. Then from apex method you can render a popup section like standard sf layout and in that popup you can update that record.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

NewInternNewIntern

"You can call an apex method through actionsupport from within inline edit support."

 

I'm wondering how I can do this when <apex:inlineEditSupport> has only the following attributes (no 'action'):

 

changedStyleClass

 

disabled

event

 

hideOnEdit

id

rendered

resetFunction

showOnEdit

 

I have an apex method that saves the checkbox selection; however, I don't know how to fire that method with inlineEditSupport (without button trigger). Earlier, I could do easily this with <apex:actionSupport> as this has the 'action' attribute. Also, having inlineEditSupport AND actionSupport together I guess doesn't accomplish anything, in which case the actionSupport action does not get triggered.

 

Require further guidance.

souvik9086souvik9086

Try something like this

 

<apex:outputField value="{!c.EJF_On_Approved__c}">
<apex:inlineEditSupport showOnEdit="saveButton" event="ondblclick">

<apex:actionsupport event="onchange" action="{!yourMethod}"/>

</apex:inlineEditSupport>
</apex:outputField>

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

 

NewInternNewIntern
Tried this earlier too. The action on actionSupport is not fired although I can fire the same action using saveButton. But as I said, I don't want a button click to invoke the apex method.