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
DipikaDipika 

inline edit support in pageblocksection

how can we use inline edit support in pageblocksection?

Navatar_DbSupNavatar_DbSup

Hi,

 

Use below code snippets as reference

 

----------------- Vf page----------------

<apex:page extensions="inlineedititng2" standardController="contact" >
 <script>
 function nn()
 {
 }
 </script>
   <apex:form id="aa" >
  <apex:pageBlock >
      <apex:pageBlockSection columns="2" >
      <apex:pageBlockSectionItem >
      <apex:outputLabel value="First Name"></apex:outputLabel>
      <apex:inputText value="{!fname}" />
  
      </apex:pageBlockSectionItem>
       <apex:commandButton value="search" reRender="pp,aa" action="{!search1}" />  
      
      </apex:pageBlockSection>
      <apex:commandButton value="save" id="save1"/>
        <apex:commandButton value="edit" id="edit1"/>
  
  <apex:pageBlockSection id="pp" >
  
  <apex:pageBlockSectionItem >
  <apex:outputLabel value="Last Name"  ></apex:outputLabel>
<apex:outputField value="{!ct.lastname}">
  <apex:inlineEditSupport event="ondblclick"/>
  
  </apex:outputField>
  </apex:pageBlockSectionItem>
  
  <apex:pageBlockSectionItem >
  <apex:outputLabel value="Email"  ></apex:outputLabel>
<apex:outputField value="{!ct.email}" >
  <apex:inlineEditSupport event="ondblclick" hideOnEdit="edit1" rendered="true" />
   </apex:outputField>
  </apex:pageBlockSectionItem>
</apex:pageBlockSection></apex:pageBlock>
</apex:form>
</apex:page>

----------- Apex controller ------------

public class inlineedititng2
 {

    public inlineedititng2(ApexPages.StandardController controller) {

    }

public string fname{get;set;}
public contact ct{get;set;}
public void search1()
{
    ct=[Select lastname,email from contact where firstname=:fname limit 1];

}

   
}

 

 Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

DipikaDipika

you didn't use inlineedit in pageblocksection. you have used this into in outfield..I want to know how can we use  inline edit support in pageblocksection..

Navatar_DbSupNavatar_DbSup

Hi,
Use this code as reference:
////////////////////////// VF Page /////////////////////////////////////////
<apex:page controller="relatedCon" id="p1">
<apex:form >
<apex:outputPanel id="Panel1">

<apex:repeat value="{!ConDetail}" var="c" >
<apex:inlineEditSupport showOnEdit="Update"
hideOnEdit="editButton" event="ondblclick"
changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
<!-- <apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton action="{!edit}" id="editButton" value="Edit"/>
<apex:commandButton action="{!Update1}" id="saveButton" value="Save" reRender="opanel1">
<apex:param name="ConId" value="{!c.id}" assignTo="{!ConId}"/></apex:commandbutton>
<apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
</apex:pageBlockButtons>
</apex:pageBlock>-->
<table width="100%" border="0" id="t1">
<tr><td width="25%"><b>Account Name</b></td>
<td width="25%">
<apex:outputField value="{!c.con.accountid}"/>
<!--<apex:inlineEditSupport showOnEdit="Update"
hideOnEdit="editButton" event="ondblclick"
changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/></apex:outputField>-->
</td></tr>
<tr><td width="25%"><b>Contact LastName</b></td>
<td width="25%">
<apex:outputField value="{!c.con.lastname}"/>
<!--<apex:inlineEditSupport showOnEdit="Update"
hideOnEdit="editButton" event="ondblclick"
changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/></apex:outputField>-->
</td></tr>
<tr><td width="25%"><b>Contact ID</b></td>
<td width="25%">
<apex:outputField value="{!c.con.id}"/></td></tr>
</table> <br/>
<center><apex:commandButton value="Update" action="{!Update1}" reRender="p1">
<apex:param name="ConId" value="{!c.con.id}" assignTo="{!ConId}"/>
</apex:commandButton></center>
<hr/>
</apex:repeat>

</apex:outputPanel>
</apex:form>
</apex:page>

/////////////////////////// Controller //////////////////////////////////////////////
public class relatedCon
{
public list<contact> ConDetail1{get;set;}
public list<wrapCon> ConDetail{get;set;}
public id conId{get;set;}
public relatedCon()
{
ConDetail=new list<wrapCon>();
ConDetail1=[select id,accountid,lastname from contact where accountid =: ApexPages.currentPage().getParameters().get('id')];
system.debug('@@@@@@@@@@@@@@@@' +ConDetail1.size());
for(contact w : ConDetail1)
{
ConDetail.add(new wrapCon(w));

}
system.debug('%%%%%%%%%%%%%%%%%%%%%%%' +ConDetail);
}
public void Update1()
{
system.debug('@@@@@@@@-------0th last--------@@@@@@@@@' +ConDetail[0].con.lastname);
system.debug('@@@@@@@@-------1st last--------@@@@@@@@@' +ConDetail[1].con.lastname);
system.debug('@@@@@@@@-------2nd last--------@@@@@@@@@' +ConDetail[2].con.lastname);
system.debug('@@@@@@@@@@@@@@@@@' +conId);
contact con2=new contact(id=conId);
con2.lastname=ConDetail[0].con.lastname;
con2.accountid=ConDetail[0].con.accountid;
update con2;
}
public void edit()
{
}
public class wrapCon
{
public contact con{get;set;}
public wrapCon(contact con1)
{
con=con1;
}
}
}

Chamil MadusankaChamil Madusanka

Refere this example

 

http://www.salesforceworld.blogspot.com/2011/06/inline-editing-in-visualforce-page.html

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.