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
Sam27Sam27 

inlineEditSupport not working properly with Wrapper class

Preface :

I really liked this <apex:inlineEditSupport> tag providing the functionality of inline edit for custom controllers.

 

I need to apply <apex:inlineEditSupport> for a table which shows matching objects. I am using Wrapper Class for getting the list of such matching objects.

 

And then showing it in the table through visualforce, Also I am rerendering the table with an ajax call.

 

Problem:

When the page loads and I double click on any item and it changes for editing according to the field type, I rerender the table and again doubleclick on any field and it again changes for editing as desired.

 

Now suppose the page is loaded and I rerender the table (without doubleclicking on any picklist field). When the table is rendered All other field works fine but picklist does not open for editing on double clicking.

 

So in short inlinEditSupport works for rerendered picklist only when any picklist field was doubleclicked when the page was loaded for the first time, Otherwise it don't.

 

Example Code :

 

Apex Class

Public class inlineEditTestController{
Public string AccSoql{get;set;}
Public integer AccCount{get;set;}
Public List<cContact> AccountVal {get;set;}
public class cContact {
  
          public Contact con {get; set;}
          public Opportunity opp {get; set;}
   
          public cContact(Contact c, Opportunity o) {
              con = c;
              opp = o;
          }
          
      }
Public pagereference inlineEditTestController(){
AccountVal = new List<cContact>();
AccSoql = 'select id, name, StageName, (select opportunitycontactrole.contact.id, opportunitycontactrole.contact.firstname, opportunitycontactrole.contact.lastname, opportunitycontactrole.contact.account.name, opportunitycontactrole.contact.Birthday__c from Opportunity.opportunitycontactroles) from opportunity order by LastModifiedDate desc';
AccCount = 10;
runQuery();
return null;
}

Public void runQuery(){
AccountVal.clear();
sObject[] newrows = Database.query(AccSoql+' LIMIT '+AccCount);
        Contact c = new Contact();
        Opportunity o = new Opportunity();
              for (SObject row : newrows){
         SObject[] childocr = row.getSObjects('OpportunityContactRoles');
      c = null;
     o = (opportunity)row;
     if(childocr != null){
     for (SObject con : childocr){
   OpportunityContactRole tempOcr = (OpportunityContactRole)con;
     c = (contact)tempOcr.contact;
     AccountVal.add(new cContact(c,o));
     }}
          }
system.debug(AccountVal.size()+'----'+AccountVal);
integer j = AccountVal.size();
if(j > 10)
{
   for(integer i=0; i<(j - 10); i++)
   {system.debug(i);
   try{
    AccountVal.remove(0);}
    catch (Exception e){}
    }
}
system.debug(AccountVal.size()+'----'+AccountVal);
}
Public pagereference moreRec(){
AccCount += 10;
runQuery();
return null;
}
Public pagereference lessRec(){
if(AccCount >= 10)
AccCount -= 10;
runQuery();
return null;
}
}

 

 

Visualforce Page

 

<apex:page controller="inlineEditTestController" action="{!inlineEditTestController}">
<apex:form >
<apex:pageBlock id="tableContainer">
<apex:pageBlockTable value="{!AccountVal}" var="Acc">
<apex:column ><apex:outputField value="{!Acc.con.LastName}"/></apex:column>
<apex:column ><apex:outputField value="{!Acc.opp.Name}"/></apex:column>
<apex:column ><apex:outputField value="{!Acc.opp.StageName}"/></apex:column>     // or any other picklist field from contact or opportunity
</apex:pageBlockTable>
</apex:pageBlock>
<apex:inlineEditSupport disabled="false" event="ondblclick"/>
<apex:commandLink action="{!moreRec}" reRender="tableContainer">More</apex:commandLink>&nbsp;&nbsp;<apex:commandLink action="{!lessRec}" reRender="tableContainer">Less</apex:commandLink>
</apex:form>
</apex:page>

 

 

Note : I am not using dependent picklist anywhere , the code provided was checked for error, without wrapperclass(i.e. for single objects) I didn't get any error and this is my first post so excuse me if I was not clear enough. Do ask me if you need some clarification.

 

Question: Is it a possible bug??

 

Anticipating quick response, Thank you.

 

Sam

Sam27Sam27

It's strange noone else is getting this problem........

 

by the way i checked and i got the problem with custom controller and contact also.

 

 

Sam27Sam27

just a test

vinodrvinodr

I am having a problem with inlineEditSupport too. It does not show the buttons mentioned in the showOnEdit attribute after I rerender the table. It works only when the page is first loaded. I wonder if there is any relation with your problem. I think it is a bug in visualforce where they are not resetting some page values after table rerender. Did you ever find a solution to this?

 

Thanks,

Vinod

Łukasz SkrodzkiŁukasz Skrodzki

@vinodr I'm encountering exactly the same issue. have you found solution for that?

 

Regards,

Łukasz

vinodrvinodr

Hi Łukasz,

 

I haven't found the solution to this exactly. I think I ended up refreshing the whole page. Have you read this btw. It might help your case. Sorry I couldn't be of much help.

 

Regards,

Vinod

anup-prakashanup-prakash

put the inlineeditsupport  above the column.