7

Ive added an inline VF page to an Event standard layout that displays a list from a related custom object. The aim is to create a false lookup relationship to get round not being able to create one normally in Events. All works fine, except when inline editing the pageblocktable. When updating multiple rows in the pageblocktable, only one record is saved and the others revert to what they were before. Any ideas? Code below:

controller

public class AttendeesInlineController {
public string eventId;
public List<Attendee__c> attended {get;set;}

public AttendeesInlineController() {

}

private ApexPages.StandardController controller {get; set;}
private Event e;


public AttendeesInlineController(ApexPages.StandardController controller)
{
    //initialize the stanrdard controller
    this.controller = controller;
    this.e = (Event)controller.getRecord();
    eventId = e.Id;
    system.debug('EEEEEEEEEEEEEEE - ' + e.Id);
    RefreshAttendees(); 
}

public void RefreshAttendees()
{
    attended = [Select Id, Client__c, EventID__c, Attended__c from Attendee__c where EventID__c =:eventId];
}

public PageReference AddAttendees()
{
    PageReference pr = Page.EventAttendees;
    pr.getParameters().put('EventId',eventId);
    return pr.setRedirect(true);    
}

public PageReference SaveInlineChanges()
{
    system.debug(attended);
    update attended;
    return ApexPages.CurrentPage();
}
}

VF

<apex:page standardController="Event" extensions="AttendeesInlineController">
<apex:form >
  <apex:pageBlock >
  <apex:pageblockButtons location="top">
      <apex:commandButton action="{!AddAttendees}" value="Add Attendees" />
      <apex:commandButton action="{!SaveInlineChanges}" value="Save" id="saveButton"/>
      <apex:commandButton action="{!CancelInlineChanges}" value="Cancel" id="cancelButton"/>
  </apex:pageblockButtons>
     <apex:pageBlockTable value="{!attended}" var="attendee">
         <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" 
                        hideOnEdit="editButton" event="ondblclick" 
                        changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
         <apex:column value="{!attendee.Client__c}"/>
         <apex:column value="{!attendee.Attended__c}"/>
     </apex:pageBlockTable>
  </apex:pageBlock>
</apex:form>
</apex:page>
9

Instead of using the "column value" method of defining the records, use the column to render an outputfield, like this:

<apex:pageBlockTable value="{!attended}" var="attendee">
     <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" 
                    hideOnEdit="editButton" event="ondblclick" 
                    changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
     <apex:column headerValue="Client">
         <apex:outputfield value="{!attendee.Client__c}"/>
     </apex:column>
     <apex:column headerValue="Attended">
         <apex:outputfield value="{!attendee.Attended__c}"/>
     </apex:column>
 </apex:pageBlockTable>

You may also want to add the inlineeditsupport into each of the Output fields to get more granular support.

| improve this answer | |

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.