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
JoeSpecJoeSpec 

hide custom buttons during inline editing

I'm trying to add some buttons conditionally to a layout.  They will only be displayed for under certain conditions (such as field values).   I've tried to override the standard view with a VF page (shown below) to add the new buttons and using the <apex:detail > tag to render the standard layout.
The problems occur with inline editing.  The buttons remain during inline editing, but if they are pushed , the inline edits don't save.  So I've tried to remove the custom buttons during inline editing, but that's not working.  Either I'd like to be able to code the buttons to save all data on the standard layout or remove them during inline editing.


 
<apex:page standardController="Allocation_Group__c"  extensions="Controller_Custom_Buttons">
<apex:form >
 <apex:inlineEditSupport hideOnEdit="TestItID" event="ondblclick">

   <div style ="padding-left:33%;">
     <apex:commandButton rendered="{!btn_AGPost_Visible}" action="{!LockIt}" value="Post AG" oncomplete="(window.top.location.href = '{!retURL}')"/>
     <apex:commandButton rendered="{!btn_AGLock_Visible}" action="{!LockIt}"  value="Lock AG" oncomplete="(window.top.location.href = '{!retURL}')"/>
     <apex:commandButton rendered="true" action="{!TestIt}"  ID="TestItID" value="Test It"/>
 </div>

   <apex:detail inlineEdit="true" subject="{!Allocation_Group__c}" relatedList="true" relatedListHover ="false" title="false" showChatter="true" /> 
   </apex:inlineEditSupport>
</apex:form>

</apex:page>
Here's the controller  .  Note I'm trying a few different approaches here but none of it is working for me.
public class Controller_Custom_Buttons {
    private final Allocation_Group__c myAG , myAGtest;
    public String retURL {get;set;}
    public Boolean btn_AGPost_Visible{get;set;}
    public Boolean btn_AGLock_Visible{get;set;}
    ApexPages.StandardController  stdController; 

    public Controller_Custom_Buttons(ApexPages.StandardController controller) {
     
    stdController=controller;
    myAGtest = (Allocation_Group__c)controller.getRecord();
    myAG = [SELECT Id, Active__c, Status__c FROM Allocation_Group__c
                  WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    if(myAG.Status__c != 'Posted')
       btn_AGPost_Visible=true;
    else
       btn_AGPost_Visible=false;
       
    if(!approval.islocked(myAG) && (myAG.Active__c==false || myAG.Status__c =='Posted') )
       btn_AGLock_Visible=true;
    else
       btn_AGLock_Visible=false;


    }
public PageReference PostIt() {

myAG.Status__c='Posted';
update myAg;
approval.lock(myAG.Id);  // doing this in trigger onAllocation_Group

retURL='/' + myAG.Id;

return null;
}
public PageReference LockIt() {

update myAg;
approval.lock(myAG.Id);  // doing this in trigger onAllocation_Group

retURL='/' + myAG.Id;

return null;
}
public PageReference TestIt() {
myAGtest.Revision_History__c='Testing';
stdController.save();
// update myAGtest;

return null;

}

}
any help would be appreciated.

Thanks,
Joe
 
JoeSpecJoeSpec
Still hoping for an answer to this?   is there any way to tell that the <apex:detail> block has gone into inline editing?  Why doesn't the stdController.save() function save the inline edits in the 'TestIt() method?

I've also tried embedding the buttons in a VF page that I embed in the standard layout, rather than override the edit page, and using the code above. That code also doesn't seem to have access to the fields in the outer page, nor am  able to tell the outer page is in in-line edit mode.

Any ideas on alternate approaches or fixes that would help one of these.  


Thanks,
Joe