Skip to main content
Updated my answer to include how to add individual elements of the wrapper.
Source Link
prashanthkr
  • 906
  • 1
  • 8
  • 20

You should have a wrapper class inside your controller that holds the custom object row and the flag:

public class TestTaskController1 {

   public class ReportInformation{
     public Report_Information__c task{get;set;}
     public Boolean saved{get;set;} 
   }

   public List<ReportInformation> reportInfos{get;set;}
 ...
}

Then on your page, you can display read-only vs editable view of the row like this:

<apex:pageBlockTable value="{!reportInfos}" var="rInfo">
      <apex:column headerValue="Report Name">
         <apex:outputField value="{!rInfo.task.Report_Name__c}" rendered="{!rInfo.saved}"/>
         <apex:inputField value="{!rInfo.task.Report_Name__c}" rendered="{!NOT(rInfo.saved)}"/>
      </apex:column>
      <br/>
      <apex:column headerValue="Comments">
           <apex:outputField value="{!rInfo.task.Comments__c}" rendered="{!rInfo.saved}"/>
           <apex:inputField value="{!rInfo.task.Report_Name__c}" rendered="{!NOT(rInfo.saved)}"/>
           <br /> 
      </apex:column>
</apex:pageBlockTable>

UPDATE:

In the constructor, set them all to false, so the input fields are displayed. Then in your action method, set it to true. You should have a list of ReportInformation items like I have in my answer. Iterate over your results from Report_Information__c and then add to the reportInfos list.

  for(Report_Information__C ri: [select id,... from Report_Information__C])
  {
   ReportInformation repInfo = new ReportInformation();
   repInfo.saved = false;
   repInfo.task = ri;
   repInfos.add(repInfo);
 }

HTH

You should have a wrapper class inside your controller that holds the custom object row and the flag:

public class TestTaskController1 {

   public class ReportInformation{
     public Report_Information__c task{get;set;}
     public Boolean saved{get;set;} 
   }

   public List<ReportInformation> reportInfos{get;set;}
 ...
}

Then on your page, you can display read-only vs editable view of the row like this:

<apex:pageBlockTable value="{!reportInfos}" var="rInfo">
      <apex:column headerValue="Report Name">
         <apex:outputField value="{!rInfo.task.Report_Name__c}" rendered="{!rInfo.saved}"/>
         <apex:inputField value="{!rInfo.task.Report_Name__c}" rendered="{!NOT(rInfo.saved)}"/>
      </apex:column>
      <br/>
      <apex:column headerValue="Comments">
           <apex:outputField value="{!rInfo.task.Comments__c}" rendered="{!rInfo.saved}"/>
           <apex:inputField value="{!rInfo.task.Report_Name__c}" rendered="{!NOT(rInfo.saved)}"/>
           <br /> 
      </apex:column>
</apex:pageBlockTable>

You should have a wrapper class inside your controller that holds the custom object row and the flag:

public class TestTaskController1 {

   public class ReportInformation{
     public Report_Information__c task{get;set;}
     public Boolean saved{get;set;} 
   }

   public List<ReportInformation> reportInfos{get;set;}
 ...
}

Then on your page, you can display read-only vs editable view of the row like this:

<apex:pageBlockTable value="{!reportInfos}" var="rInfo">
      <apex:column headerValue="Report Name">
         <apex:outputField value="{!rInfo.task.Report_Name__c}" rendered="{!rInfo.saved}"/>
         <apex:inputField value="{!rInfo.task.Report_Name__c}" rendered="{!NOT(rInfo.saved)}"/>
      </apex:column>
      <br/>
      <apex:column headerValue="Comments">
           <apex:outputField value="{!rInfo.task.Comments__c}" rendered="{!rInfo.saved}"/>
           <apex:inputField value="{!rInfo.task.Report_Name__c}" rendered="{!NOT(rInfo.saved)}"/>
           <br /> 
      </apex:column>
</apex:pageBlockTable>

UPDATE:

In the constructor, set them all to false, so the input fields are displayed. Then in your action method, set it to true. You should have a list of ReportInformation items like I have in my answer. Iterate over your results from Report_Information__c and then add to the reportInfos list.

  for(Report_Information__C ri: [select id,... from Report_Information__C])
  {
   ReportInformation repInfo = new ReportInformation();
   repInfo.saved = false;
   repInfo.task = ri;
   repInfos.add(repInfo);
 }

HTH

Source Link
prashanthkr
  • 906
  • 1
  • 8
  • 20

You should have a wrapper class inside your controller that holds the custom object row and the flag:

public class TestTaskController1 {

   public class ReportInformation{
     public Report_Information__c task{get;set;}
     public Boolean saved{get;set;} 
   }

   public List<ReportInformation> reportInfos{get;set;}
 ...
}

Then on your page, you can display read-only vs editable view of the row like this:

<apex:pageBlockTable value="{!reportInfos}" var="rInfo">
      <apex:column headerValue="Report Name">
         <apex:outputField value="{!rInfo.task.Report_Name__c}" rendered="{!rInfo.saved}"/>
         <apex:inputField value="{!rInfo.task.Report_Name__c}" rendered="{!NOT(rInfo.saved)}"/>
      </apex:column>
      <br/>
      <apex:column headerValue="Comments">
           <apex:outputField value="{!rInfo.task.Comments__c}" rendered="{!rInfo.saved}"/>
           <apex:inputField value="{!rInfo.task.Report_Name__c}" rendered="{!NOT(rInfo.saved)}"/>
           <br /> 
      </apex:column>
</apex:pageBlockTable>