1

the Inline Editing doesn't work in the pageBlockTable (editable but doesn't update changes).

my suspicions its related to the need to update controller object from sql query running on costume object.

buy i don't know how to solve it , because its the best method to get this specific data. Any ideas?

Thank you.

Visualforce Page

<apex:page showHeader="false" sidebar="false" standardController="ACCOUNT"  extensions="BackStationsController">
 <apex:form >

 <apex:pageBlock title="Room Deatels" >

<apex:pageBlockButtons location="bottom">

   <apex:commandButton action="{!save}" id="saveButton" value="Save" rendered="true"/>
  </apex:pageBlockButtons>
  <apex:pageMessages /> 

  <apex:pageBlockSection columns="1"  title="Room Guests List" rendered="TRUE" collapsible="false">

    <apex:pageBlockTable value="{!constroom}" var="croom"  rows="5">
     <apex:inlineEditSupport event="ondblclick"   changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> 


       <apex:column headerValue="Local ID" value="{!croom.PasiveAccount__r.Local_ID__c}"/>
      <apex:column headerValue="First Name" value="{!croom.PasiveAccount__r.firstname}"/>
      <apex:column headerValue="Last Name" value="{!croom.PasiveAccount__r.lastname}"/>
      <apex:column headerValue="Email" value="{!croom.PasiveAccount__r.PersonEmail}"/>
       <apex:column headerValue="Phone" value="{!croom.PasiveAccount__r.phone}"/>


    </apex:pageBlockTable>
  </apex:pageBlockSection>

     </apex:outputPanel>
             </apex:pageBlock>


</apex:form>

Extension

public with sharing class BackStationsController {



  public BackStationsController(ApexPages.StandardController std) {
     stdCtrl=std;
     integer  Tempcount = [Select Count() from UnitCloneJunc__c where ActiveAccount__r.id =:stdCtrl.getId()];
     if (stdCtrl.getId() != NULL && temp >0 )
        setupRoomchange();
}


private ApexPages.StandardController stdCtrl {get; set;}
public List<UnitCloneJunc__c> constroom {get; set;} 


Private void setupRoomchange(){
   constroom=[select  ID,PasiveAccount__r.phone, PasiveAccount__r.firstname, PasiveAccount__r.lastname,PasiveAccount__r.PersonEmail,PasiveAccount__r.Local_ID__c from UnitCloneJunc__c where id != null and ActiveAccount__r.isPersonAccount = true and ActiveAccount__r.id =:stdCtrl.getId() order by CreatedDate ASC];
  }
  • Just a quick note - When editing a field you MUST click outside the field or hit tab in order for the change to be saved. Just in case this may be your issue. Always hated that and one of the main reasons I never use inline edit but use other means to allow editing while still displaying the information (JS, Bootstrap, Angular, etc) – Eric Oct 3 '15 at 22:54
  • Also, you need to have a rerender in your command button - It could simply be rerender="" – Eric Oct 3 '15 at 22:55
0

One problem is that the save method of the standard controller will save the Account it has queried but it looks like you want to save you want to save the objects referenced via PasiveAccount__r. (Perhaps they are Account objects too). So you need to add your own save method:

public PageReference save() {
    Map<Id, SObject> sobs = new Map<Id, SObject>();
    for (UnitCloneJunc__c c : constroom) {
        sobs.add(c.PasiveAccount__r.Id, c.PasiveAccount__r);
    }
    update sobs.values();
    return stdCtrl.view();
}

I've used a map in case the same object is referenced in more than one row; if that is a possibility it would be better to filter the duplicates in your setupRoomchange method.

  • Hi Keith, thank you. yes i would like to update PasiveAccount__r which is Account. though its a different account then the controller. – Oron M Oct 4 '15 at 10:17
  • Hi Keith, thank you. though it dosent work. constroom sql return multiple PasiveAccount__r, how would it knows to update the spacific PasiveAccount__r been edited? im using in a in a diffrenete table (but similar use) a commandlink ('delete guest') and <apex:param name="selAccId" value="{!croom.Id}" assignTo="{!selectedelId}" /> to pass the selected Account id parameter . but i dont know how to do it with Inline edit. – Oron M Oct 4 '15 at 18:22
  • @OronM Visualforce automatically binds the HTML form fields to the underlying multiple SObjects in the Apex controller - you don't need to do anything like pass ID values for it to work. I don't know why it is not working for your code. – Keith C Oct 4 '15 at 21:24

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.