You need to sign in to do that
Don't have an account?
navy11jain@hotmail.com
How to mass update (inline edit) many records with StandardSetController ??? Please help - URGENT
Hi Rajat,
this is code below i modofied and it's working oerfectly 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} </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 </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;
}
}
}
if it's wothfull please mark it as a solution.
this is code below i modofied and it's working oerfectly 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} </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 </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;
}
}
}
if it's wothfull please mark it as a solution.
Please let me know if you are still facing the issue.