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
Irene SlessIrene Sless 

Redirect delete button in repeating apex:detail section on VF page

My VF page queries a custom object as the main object, and then has a repeating section of a child object which is displayed using apex:detail. This works very nicely for everything, except the delete, which redirects to the list page and not to the VF page.

I would like the delete button to delete the child section from the repeating part, and return to the parent page. 
User-added image
<apex:page StandardController="CallCycle__c" extensions="CallCycleController" title="Call Cycles" showHeader="true" sidebar="true">
    
    <style>
        .cc_row { padding: 7px 0px;  }
        .cc_margin{ margin:3px 8px 3px 8px; }        
        .cc_col3{ width: 3%; }
        .cc_col5{ width: 5%; }
        .cc_col8{ width: 8%; }
        .cc_col10{ width: 10%; }
        .cc_col15{ width: 15%; }
        .cc_col20{ width: 20%; }
        .clear-both{ clear: both; }
        .center{ text-align: center; }
        .title{ font-weight: bold;
        padding: 5px; }
    </style>
    
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script type="text/javascript">
        
        jCC$ = jQuery.noConflict();
    
    jCC$(document).ready(function() {
        
        jCC$(".hideContacts").click(function() {
            var isChecked = this.checked;
            
            if(isChecked){
                
                jCC$(".dataRow").each(function() {
                    var c = jCC$(this).find(".checkContact");
                    //var p = jCC$(this).find('.checkContact').val();
                    if(c != undefined && !c.is(":checked")){
                        jCC$(this).hide();
                    }
                });
            }
            else{
                jCC$(".dataRow").show();
            }
        });
                
    });
    
    function updateDisplay(checkbox, id){
        
        var checked = checkbox.checked;
        CallCycleControllerX.RemoteUpdateisSelected(id, checked, function(result, event){
            var foo = result;
        });
        
    }
    
    function updateEventDateTime(id, dateTime){ 
        var r = confirm("Are you sure you want to generate these events?");               
        updateEventDate(id, dateTime);
    }
    
    </script>
    
    <apex:form >
        
        <apex:sectionHeader title="Call Cycle Schedule" subtitle="{!CallCycle.Name}" />
        <apex:outputLink value="{!URLFOR($Action.CallCycle__c.Tab, $ObjectType.CallCycle__c)}">Back to list: CallCycles</apex:outputLink>
        
        <apex:pageBlock title="Call Cycle Detail">
            <apex:pageMessages />
            <apex:pageBlockButtons location="top">                
                <apex:commandButton id="PrintAdmin" action="PrintCallCycle" title="Print Call Cycle" value="Print Admin Call Cycle" onclick="window.open('/apex/CallCyclePrint?id={!CallCycle.Id}');return false;" />                
                <apex:commandButton id="PrintRep" action="PrintCallCycle" title="Print Call Cycle" value="Print Rep Call Cycle" onclick="window.open('/apex/CallCyclePrintRepTable?id={!CallCycle.Id}');return false;" />
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="" collapsible="false">
                <apex:outputField id="Name" value="{!CallCycle__c.Name}" />
                <apex:outputField id="Date" value="{!CallCycle__c.Date__c}" />
                <apex:outputField id="SalesPerson" value="{!CallCycle__c.SalesPerson__c}" />
                <apex:outputField id="CycleStart" value="{!CallCycle__c.CycleStart__c}" />
                <apex:inputCheckbox id="HideContacts" label="Hide Unselected Contacts" styleClass="hideContacts" value="{!HideContacts}" />
                <apex:outputField id="CycleEnd" value="{!CallCycle__c.CycleEnd__c}" />
            </apex:pageBlockSection>            
        </apex:pageBlock>        
        <apex:pageBlock title="Edit Call Cycle">
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton id="AddToCallCycle" action="{!AddToCallCycle}" title="Add New Account" value="Add New Account to Call Cycle" styleClass="center" />
                <apex:commandButton id="updateAllNewDate" action="{!UpdateCCADateAll}" title="Update All New Date" value="Update All Appointments with New Date" />
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="" collapsible="false">
                <apex:inputField id="Account" value="{!AddCallCycleActivity.Account__c}" label="Add a new Account" required="false"/>
                <apex:inputField label="New Appointment Date for All in Call Cycle" id="theAllDate" styleClass="theDate" value="{!UpdateCCADateAll.EventDate__c}" required="false"/>
                <apex:inputField id="NewDateTime" value="{!AddCallCycleActivity.EventDateTime__c}" label="Date/Time of Appointment for new Account" required="false"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock title="Call Cycle Events">                        
            <apex:repeat value="{!CallCycleActivitiesEx}" var="activity">
                <apex:pageBlock >
                    <apex:detail subject="{!activity.CallCycleActivity.Id}" relatedList="false" inlineEdit="true" title="false"/>
                    <apex:pageblockTable styleClass="cc_row" width="95%" rowClasses="odd,even" value="{!activity.CallCycleActivity.CallCycleActivityContacts__r}" var="contact">
                        <apex:column styleclass="cc_col5" headerValue="CRMGroup">
                            <apex:inputCheckbox title="{!contact.Id}" value="{!contact.IsSelected__c}" styleClass="checkContact" onclick="updateDisplay(this, '{!contact.Id}');" />{!contact.Contact__r.AccredoCRMGroup__c}
                        </apex:column>
                        <apex:column styleclass="cc_col8" headerValue="Contact Name">
                            <apex:outputLink value="{!URLFOR($Action.Contact.View, contact.Contact__r.Id)}" target="_blank">{!contact.Contact__r.Name}</apex:outputLink>
                        </apex:column>
                        <apex:column styleclass="cc_col5" headerValue="Phone Number" value="{!contact.Contact__r.Phone}"/>
                        <apex:column styleclass="cc_col8" headerValue="Mobile Phone" value="{!contact.Contact__r.MobilePhone}"/>
                        <apex:column styleclass="cc_col8" headerValue="Email" value="{!contact.Contact__r.Email}"/>
						<apex:column styleclass="cc_col5" headerValue="Department" value="{!contact.Contact__r.Department}"/>
                        <apex:column styleclass="cc_col5" headerValue="Title" value="{!contact.Contact__r.Title}"/>
                        <apex:column styleclass="cc_col3" headerValue="Confirm" value="{!contact.Contact__r.ConfirmAppointment__c}"/>
                        <apex:column styleclass="cc_col3" headerValue="Include" value="{!contact.Contact__r.IncludeinCallCycle__c}"/>
                        <apex:column styleclass="cc_col5" headerValue="Last Visit" value="{!contact.Contact__r.LastCallCycleVisit__c}"/>
                        <apex:column styleclass="cc_col5" headerValue="Pref Method" value="{!contact.Contact__r.PreferredContactMethod__c}"/>
                        <apex:column styleclass="cc_col8" headerValue="Pref Day" value="{!contact.Contact__r.Preferred_Day__c}"/>
                        <apex:column styleclass="cc_col5" headerValue="Pref Time" value="{!contact.Contact__r.Preferred_Time__c}"/>
                        <apex:column styleclass="cc_col8" headerValue="Pref Time Other" value="{!contact.Contact__r.Preferred_Time_Other__c}"/>
                        <apex:column styleclass="cc_col5" headerValue="Connect" value="{!contact.Contact__r.MailAgedCareConnect__c}"/>
						<apex:column headerValue="Alarm" value="{!contact.Contact__r.AccredoAlarms__c}"/>                        
                    </apex:pageblockTable>                    
                </apex:pageBlock>                
            </apex:repeat>            
        </apex:pageBlock>        
    </apex:form>    
</apex:page>