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
bsil bsilbsil bsil 

Inline Edit In apex:pageblocktable

HI,

Here i am facing issue with inlinedit in apex:pageblock table...

i am dispalying some list of records in a table..

see the below code:

Visualforce page:

<apex:page standardController="Project__c" extensions="projectopportunities" docType="xhtml-1.0-strict"> 
    <apex:form >
    <div id='inCompletedproj' style='border:0px solid;overflow-y:scroll;height:200px;'>
    <apex:pageBlock id="tbid" mode="inlineedit"> 
         <apex:pageBlockButtons location="top"> 
                <apex:commandButton action="{!addnewopp}" value="Add New Opportunity" onclick="window.open('/apex/new_opportunity_for_project_page?pid={!proid}')"/>                
           </apex:pageBlockButtons>
            <apex:pageBlockButtons location="bottom"> 
               <apex:commandButton action="{!saveme}" id="saveButton" value="Save" />
               <apex:commandButton id="cancelButton" value="Cancel"/> 
           </apex:pageBlockButtons>
         <apex:pageMessages></apex:pageMessages>
           <apex:pageBlockTable value="{!opplist}" var="p" id="tableid">            
          <apex:column >
                    <apex:outputlink Onclick="window.open('/{!p.id}/e?retURL={!p.Project__c}');return false;"><div style="color:blue;">Edit</div></apex:outputlink> 
                    <apex:facet name="header">Action</apex:facet>
                </apex:column>
                <apex:column >
                    <apex:outputField value="{!p.accountid}">
                        <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                        <apex:facet name="header">Account Name</apex:facet>
                </apex:column>
                <apex:column value="{!p.name}">
                    <!--<apex:outputField value="{!p.name}"/>--> 
                        <apex:facet name="header">Opportunity Name</apex:facet>
                </apex:column>                
               <apex:column >
                   <apex:outputField value="{!p.Amount_Integer__c}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">Dealer Cost</apex:facet>
               </apex:column>
               <apex:column >
                   <apex:outputField value="{!p.CloseDate}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">Est. Close Date</apex:facet>
               </apex:column>
               <apex:column >
                   <apex:outputField value="{!p.StageName}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">Stage</apex:facet>
               </apex:column>
               <apex:column >
                   <apex:outputField value="{!p.Product_Group__c}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">Product Group</apex:facet>
               </apex:column>
               <apex:column >
                   <apex:outputField value="{!p.SubProductGroup__c}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">SubProduct Group</apex:facet>
               </apex:column>
       </apex:pageBlockTable>
   
</apex:pageBlock> 
        </div>
</apex:form> 
</apex:page>

Apex Class:

public with sharing class projectopportunities{
   
    public id proid{get;set;}
    public List<Opportunity> opplist{get;set;}   
    public projectopportunities(){}   
    public String Url{get;set;}
    public RecordType RT;
    public projectopportunities(ApexPages.StandardController controller) {      
        //opplist = new List<Opportunity>();
        proid = apexpages.currentpage().getparameters().get('id'); 
         RT = [Select Id From RecordType where sobjecttype = 'Opportunity' and name ='project'];
        opplist= [Select Id,Name,Accountid,Project__c,Amount_Integer__c,CloseDate,StageName,Product_Group__c,SubProductGroup__c From Opportunity where Project__c =: proid and recordtypeid =:RT.id];   
    }
   
    public pagereference saveme()
    {
       
        try
        {     
            update opplist;
            opplist.clear();
            opplist= [Select Id,Name,Accountid,Project__c,Amount_Integer__c,CloseDate,StageName,Product_Group__c,SubProductGroup__c From Opportunity where Project__c =: proid and recordtypeid =:RT.id];
        }  
        catch(Exception e)
        {
            System.debug('Exception occurred '+String.valueOf(e));
            ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.Error,'Only specify the winner account in the Account Name field for a Won Opportunity.'));
        }
        return null;
    }
   
    public pagereference addnewopp(){      
       
        //return new PageReference('/apex/new_opportunity_for_project_page?pid='+proid);
        return null;
        
    }
   
}



here i am updating all records which are in table......

here i want to update only particular record  
Deepak Kumar ShyoranDeepak Kumar Shyoran
As you are saying that you only want to update only selected records not all records displaying on V.F so you need to display a list of Wrapper Class on V.F which display your current records as you are displaying them now along with a Checkbox field.

And then by using that additional checkbox create a list of record you want to update and then finally update them.

Please mark it as best solution to your problem if it does solve your problem.
bsil bsilbsil bsil
 Thanks Deepak,

Here i am not going to provide checkbox, only dbclick  i am using ti edit the field...........................