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
Amit Singh MumbaiAmit Singh Mumbai 

How to use Inline editing in Visualforce page.

Hi friends,

i have Follwing objects

Job

Quotes

Estimate line item (Estimate)

GLCode etc.

i am focusing on Estimate object and GLCode object because my question is related to these two objects only.

 

On GLCode and Estimate, a picklist field is there,

Department (values are same for both the object, values are- Computer services,Photography and production)

 

GL Code is master of Estimate Object (lookup relationship).

 

first we need to create GL Code in which Department field is required.

 

Now when we create any Estimate then first we select department then we select GLCode (Only those GLCode will be populated for which Department is same as Department selected on Estimate... because on GLCodes lookup we are using filter criteria).

 

i have created a vf page where i am displaying list of Etimates... here i am using inline edit support...

Inline edit support is set for Department as well as GlCode.

i am getting problem while using inline editing , when i changed Department ,then clicked on GlCode ( i am not getting glcode based on new selected department in my lookup window... it shows based on previous on)...

How to solve this kind ob issue?

 

here is my Code.

 

thanks in Advance

<apex:page Controller="DisplayEstimateunderJobTab">
<head>
<script>
function buttonClicked(myButton) {
    myButton.disabled=true;
    return false;
}
</script>
 
<style>

    
.labelCol2{font-size:1.0em};
</style>
</head>
 <apex:form >
  <apex:pageMessages />
  
   <apex:pageBlock tabStyle="Vendor_Quote__c" mode="edit">
 
     <div>
     <h1>Estimate Line Items </h1>
   
    
     <apex:commandButton action="{!CreateVQ}" value="New Line Item" id="btn1"/> 
     </div> 
   <center>  <apex:commandButton value="Save" action="{!save}" id="saveButton" style="display: none;"/>  
     <apex:commandButton value="Cancel" id="cancelButton" onclick="resetInlineEdit()" style="display: none;"/>   </center>
      &nbsp;
      <div>
      <apex:pageBlockTable value="{!vq}" var="vquote" rendered="{!vq.Size > 0}"> <br/><br/><br/> 
         <apex:column headerValue="Action">
         
         
             <apex:commandButton value="Approve" action="/apex/ApproveEstimate?id={!vquote.id}" id="myButton" oncomplete="return buttonClicked(this);"/>  
         </apex:column>
         
         <apex:column headerValue="Approved">
          <apex:outputField value="{!vquote.Approved__c}"/>
          </apex:column>  
         
          <apex:column headerValue="Name">
         <apex:outputLink tabindex="tab1" value="/apex/Estimatedetailpage?id={!vquote.Id}">{!vquote.Name}</apex:outputLink>
          </apex:column> 
                   
          <apex:column headerValue="Vendor">
          <apex:outputfield value="{!vquote.Vendor__r.Name}"/>
          </apex:column>
          
           <apex:column headerValue="PO Created">
          <apex:outputField value="{!vquote.PO_Created__c}"/>
          </apex:column> 
          
          
          <apex:column headerValue="Department">
       
       <apex:outputField value="{!vquote.GL_Department__c}" >
        <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="btn1" rendered="{!vquote.PO_Created__c = false}" resetFunction="resetInlineEdit"/> </apex:outputfield> 
        
          </apex:column> 
 
<apex:column headerValue="GL Code"> <apex:outputField value="{!vquote.GL_Code__c}"> <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="btn1" rendered="{!vquote.PO_Created__c = false}" resetFunction="resetInlineEdit"/> </apex:outputfield> </apex:column> <apex:column headerValue="Unit Type"> <apex:outputfield value="{!vquote.Unit_Type__c}"/> </apex:column> <apex:column headerValue="Quantity"> <apex:outputfield value="{!vquote.Quantity__c}"> <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="btn1" rendered="{!vquote.PO_Created__c = false}" resetFunction="resetInlineEdit"/> </apex:outputfield> </apex:column> <apex:column headerValue="Unit Cost"> <apex:outputfield value="{!vquote.Amount__c}"/> </apex:column> <apex:column headerValue="Total Cost"> <apex:outputfield value="{!vquote.Total_Amount__c}"/> </apex:column> </apex:pageBlockTable> <br/> <div style="float:right;padding-right:65px;font-size:1.10em;font-style:normal;font-family: 'Calibri';font-weight:bold"> <apex:outputPanel rendered="{!vq.Size > 0}"> <apex:outputLabel value="Total Cost ($)" style="font-style:italic;" /> <apex:outputText value="{0,Number, ###,###,###.00}"> <apex:param value="{!sumCash}"/> </apex:outputText> </apex:outputPanel> </div> </div> <br/> <apex:pageBlockSection rendered="{!vq.size <= 0}"> <apex:pageBlockSectionItem > No records to display. </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
Controller

public class DisplayEstimateunderJobTab
{

public List<Estimate_Line_Items__c> vq{get;set;}
public List<Estimate_Line_Items__c> vq1{get;set;} 
String theID;
    public DisplayEstimateunderJobTab() 
    {
 theID = ApexPages.CurrentPage().getParameters().get('id');
 vq=[select id,Name,Approved__c,PO_Created__c,GL_Code__r.Name,GL_Department__c,Job__c,Vendor__r.Name,Quote__r.Name,Amount__c,Total_Amount__c,Quantity__c,Unit_Type__c from Estimate_Line_Items__c where Job__c =: [Select id from Job__c where id =: theID] Order By Name];
    
    
    }
    
        
    public double getSumCash()  
    {
            SObject sumCash;  
            sumCash = [SELECT SUM(Total_Amount__c) sum FROM Estimate_Line_Items__c WHERE Job__c =: [Select id from Job__c where id =: theID] and Approved__c = true];
            
            return double.valueOf(sumCash.get('sum'));
   }
    
     public PageReference save()
    {
    try
     {
      update vq;
     }
     catch(System.DMLException e)
               {
                 return null;
               }
     return null;
    }
    

   
    
    
    
     public PageReference CreateVQ()
    {
       String jobid;
       String theId=ApexPages.CurrentPage().getParameters().get('id');
       Estimate_Line_Items__c est = new Estimate_Line_Items__c();
       Job__c job = [Select Id from Job__c where id =: theID];
       jobid=job.Id;
       
      PageReference p = Page.CreateNewEstimate;
       p.setredirect(true);
     p.getParameters().put('jobid',theID); 
     return p;
     //return null;
    }