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
Rajat Mahajan 14Rajat Mahajan 14 

How to mass update (inline edit) many records with StandardSetController ??? Please help - URGENT

Hi Guys

This is the code i have : 

PAGE :

<apex:page standardcontroller="Account" extensions="StudentsController" >
  
<script>
alert("Checkvalue");
alert({!acctSSC});
function displayErr(){
      window.alert("Checkvalue:");
}
</script>
   
    <apex:form id="theForm">

        <apex:inlineEditSupport />
   
        <apex:pageBlock Title="All Students List" id="pbAccts">
           
            <apex:pageblockbuttons location="bottom">
                <apex:commandbutton value="Save" action="{!saveAccounts}" onclick="dislayErr()" />
                <apex:commandbutton value="Cancel" action="{!cancel}"/>
            </apex:pageblockbuttons>
           
            <apex:pageBlockTable value="{!accounts}" var="a">
                <apex:column value="{!a.name}"/>
                <apex:column value="{!a.website}"/>
                <apex:column value="{!a.phone}"/>
            </apex:pageBlockTable>
              
        <br/>
       
        <apex:outputText value="Please select the number of records to be displayed : "/>
                   
            <apex:selectList size="1" value="{!pageSize}">
                <apex:selectOptions value="{!pageSizes}"/>
                      <apex:actionSupport event="onchange" action="{!updateStandardSetController}" rerender="theForm"/>
            </apex:selectList>
           
            <apex:outputPanel layout="block" styleClass="pSearchShowMore" id="otpNav2">
               
            <!-- <apex:outputText rendered="{!IF(acctSSC.resultSize < 10000,true,false)}"> <b> TOTAL </b> : {!acctSSC.resultSize} &nbsp;&nbsp;&nbsp; </apex:outputText> -->
               
                <apex:commandLink value="Previous Page " action="{!previous}" rendered="{!acctSSC.HasPrevious}" rerender="pbAccts" />  
                <apex:outputPanel style="color: grey;" rendered="{!NOT(acctSSC.HasPrevious)}">Previous Page &nbsp; </apex:outputPanel>        
                <apex:outputPanel style="color:grey;" rendered="{!NOT(acctSSC.HasNext)}">Next Page</apex:outputPanel>        
                <apex:commandLink action="{!next}" value="Next Page" rendered="{!acctSSC.HasNext}" rerender="pbAccts"/>
     
            </apex:outputPanel>
           
        </apex:pageBlock>   
       
    </apex:form>
   
</apex:page>

APEX :

/*
* Description : Controller Class for Students List Page
* Author : Rajat Mahajan
*/

public class StudentsController {

    public StudentsController (ApexPages.StandardController controller){
        pageSize = '5';
        updateStandardSetController();
    }
 
    //Page record size variable 
    public string pageSize {get;set;}
   
    //Standard Set Controller variable for taking all students records (Standard Set controllers methods will be used for working with the collection of records - like pagination)
    public ApexPages.Standardsetcontroller acctSSC {get;set;}
   
    //Constructor will set the default page size of records and also call the method to fetch records   
    public StudentsController (){
       
    }
   
    //Method to fetch records and display only page size records
    public void updateStandardSetController(){
        acctSSC = new ApexPages.Standardsetcontroller(Database.getQuerylocator([SELECT Id, name, website, phone FROM Account]));
        acctSSC.setPageSize(integer.valueOf(pageSize));
    }
   
    //Method to get all records on to the page
    public List<Account> getAccounts(){
        return acctSSC.getRecords();
    }
   
    //Method to set the number of records on the page to be displayed as per user option
    public List<SelectOption> getPageSizes(){
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('5','5'));
        options.add(new SelectOption('10','10'));
        options.add(new SelectOption('20','20'));
        options.add(new SelectOption('50','50'));
        options.add(new SelectOption('100','100'));
        return options;
    }
   
    //Returns true/false based on records present or not
    public Boolean hasNext{
        get{
            return acctSSC.getHasNext();
        }
        set;
    }

    //Returns true/false based on records present or not
    public Boolean hasPrevious{
        get{
            return acctSSC.getHasPrevious();
        }
        set;
    }

    //Returns previous page of records if present
    public void previous(){
        acctSSC.previous();
    }

    //Returns next page of records if presen
    public void next(){
        acctSSC.next();
    }
   
    public void saveAccounts(){      
       // update acctSSC;      
    }
   
}

---------------------------------
The method saveAccounts :
If i remove the comment : // update acctSSC; (I am basically trying to save the records of StandardSetcontroller

Then i get the following compile time error :
Error Error: StudentsController Compile Error: DML requires SObject or SObject list type: ApexPages.StandardSetController at line 73 column 9

Can you please help me , acctSSC is already of type StandardSetController - I may be doing some mistake.

Please let me know

Regards
MagulanDuraipandianMagulanDuraipandian
http://www.infallibletechie.com/2014/05/how-to-get-selected-records-from.html

Check this!!!

If this solves your problem, kindly mark it as the best answer.
Hit Like, if it saved your work :-)

Regards,
Magulan
http://www.infallibletechie.com
Ramu_SFDCRamu_SFDC
You might have to look at the below article which has the complete code for similar requirement

http://www.mindfiresolutions.com/How-to-use-Inline-Edit-in-a-custom-Visualforce-UI-Page-2278.php
navy11jain@hotmail.comnavy11jain@hotmail.com
Hi Rajat,
i modified this code as you are expecting:

<apex:page standardcontroller="Account" extensions="StudentsControllernew"  >
 
<script>
alert("Checkvalue");
alert({!acctSSC});
function displayErr(){
      window.alert("Checkvalue:");
}
</script>
  
    <apex:form id="theForm" >

        <apex:inlineEditSupport />
  
        <apex:pageBlock Title="All Students List" id="pbAccts">
          
            <apex:pageblockbuttons location="bottom">
                <apex:commandbutton action="{!saveAccounts}" value="Save" id="saveButton"  />
                <apex:commandbutton value="Cancel" action="{!cancel}"/>
            </apex:pageblockbuttons>
          
            <apex:pageBlockTable value="{!acclist}" var="a" >
            <!--    <apex:column value="{!a.name}"/>
                <apex:column value="{!a.website}"/>
                <apex:column value="{!a.phone}"/> -->
                 <apex:column headerValue="Name">
            <apex:outputField value="{!a.Name}"/>
         </apex:column>
         <apex:column headerValue="Phone">  
            <apex:outputField value="{!a.phone}">
               <apex:inlineEditSupport showOnEdit="saveButton" event="ondblclick"/>   
            </apex:outputField>
          </apex:column> 
           <apex:column headerValue="website">  
            <apex:outputField value="{!a.website}">
               <apex:inlineEditSupport showOnEdit="saveButton" event="ondblclick"/>   
            </apex:outputField>
          </apex:column>
            </apex:pageBlockTable>
             
        <br/>
      
        <apex:outputText value="Please select the number of records to be displayed : "/>
                  
            <apex:selectList size="1" value="{!pageSize}">
                <apex:selectOptions value="{!pageSizes}"/>
                      <apex:actionSupport event="onchange" action="{!updateStandardSetController}" rerender="theForm"/>
            </apex:selectList>
          
            <apex:outputPanel layout="block" styleClass="pSearchShowMore" id="otpNav2">
              
            <!-- <apex:outputText rendered="{!IF(acctSSC.resultSize < 10000,true,false)}"> <b> TOTAL </b> : {!acctSSC.resultSize} &nbsp;&nbsp;&nbsp; </apex:outputText> -->
              
                <apex:commandLink value="Previous Page " action="{!previous}" rendered="{!acctSSC.HasPrevious}" rerender="pbAccts" /> 
                <apex:outputPanel style="color: grey;" rendered="{!NOT(acctSSC.HasPrevious)}">Previous Page &nbsp; </apex:outputPanel>       
                <apex:outputPanel style="color:grey;" rendered="{!NOT(acctSSC.HasNext)}">Next Page</apex:outputPanel>       
                <apex:commandLink action="{!next}" value="Next Page" rendered="{!acctSSC.HasNext}" rerender="pbAccts"/>
    
            </apex:outputPanel>
          
        </apex:pageBlock>  
      
    </apex:form>
  
</apex:page>

public class StudentsControllernew {

        public String message{get;set;}
        public list<account> acclist {get;set;}
       
       public StudentsControllernew(ApexPages.StandardController controller){
        pageSize = '5';
        acclist = [SELECT Id, name, website, phone FROM Account limit 50000];
        updateStandardSetController();
    }

    //Page record size variable
   public string pageSize {get;set;}
  
    //Standard Set Controller variable for taking all students records (Standard Set controllers methods will be used for working with the collection of records - like pagination)
    public ApexPages.Standardsetcontroller acctSSC {get;set;}
  
    //Constructor will set the default page size of records and also call the method to fetch records  
     
    //Method to fetch records and display only page size records
    public void updateStandardSetController(){
      //   acclist = [SELECT Id, name, website, phone FROM Account limit 50000];
       acctSSC = new ApexPages.Standardsetcontroller(Database.getQuerylocator([SELECT Id, name, website, phone FROM Account]));
       acctSSC.setPageSize(integer.valueOf(pageSize));
       //update acclist;
      // return null;
    }
  
    //Method to get all records on to the page
  //  public List<Account> getAccounts(){
//       return acclist;
  //  }
  
    //Method to set the number of records on the page to be displayed as per user option
    public List<SelectOption> getPageSizes(){
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('5','5'));
        options.add(new SelectOption('10','10'));
        options.add(new SelectOption('20','20'));
        options.add(new SelectOption('50','50'));
        options.add(new SelectOption('100','100'));
        return options;
    }
  
    //Returns true/false based on records present or not
    public Boolean hasNext{
        get{
            return acctSSC.getHasNext();
        }
        set;
    }

    //Returns true/false based on records present or not
    public Boolean hasPrevious{
        get{
            return acctSSC.getHasPrevious();
        }
        set;
    }

    //Returns previous page of records if present
    public void previous(){
        acctSSC.previous();
    }

    //Returns next page of records if presen
    public void next(){
        acctSSC.next();
    }
    public pagereference saveAccounts(){     
        try{
         update acclist;
         PageReference nextpage= new PageReference('/apex/accounteditingfinal');
          nextpage.setredirect(true);
           return nextpage;
      }
      catch(Exception e){
            message='Data Base error during saving...';
            ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.ERROR, message));
            return null;
        }  
   }
     
}

please mark this as a solution if it is worthfull