You need to sign in to do that
Don't have an account?
Ashish Kumar Yadav
how to display data using pagination with limit and offset
Hello Team ,
anyone please help me regarding to display the record using pagination.i want to display the record on button click.getting the error-Unknown property 'AssignScheme.membs'.i am calling the method below button.
vf page
=======
<apex:commandButton styleClass="slds-button slds-button_brand" value="Show Asignment" action="{!getAccount_apex}" onclick="reloadPage()" reRender="outptText">
</apex:commandButton>
<apex:repeat value="{!membs }" var="awl" >
<tr class="slds-hint-parent">
<th scope="row">
<div class="slds-form-element__control">{!awl.scheme.Account__r.Name}</div>
</th>
<td data-label="" class="fromvalue">
<div class="slds-form-element__control">{!awl.scheme.Account__r.SF_Customer_Code__c}</div>
</td>
<td data-label="" class="fromvalue">
<div class="slds-form-element__control">{!awl.scheme.Account__r.SAP_Customer_Code__c}</div>
</td>
<td data-label="">
<apex:commandButton styleClass="slds-button slds-button_destructive" value="Delete" action="{!Remove}" onclick="reloadPage()" >
</apex:commandButton>
</td>
</tr>
</apex:repeat>
</tbody>
apex code
===========
public List<Scheme_Assign_Master__c> getAccount_apex() {
String scheme2=sam.Scheme_Master__c;
List<Scheme_Assign_Master__c> membs =Database.Query('SELECT Id,Account__c,Account__r.Name,Account__r.SF_Customer_Code__c,Account__r.SAP_Customer_Code__c, Scheme_Master__c from Scheme_Assign_Master__c where Scheme_Master__c =:scheme2 LIMIT :blockSize OFFSET :index');
System.debug('Values are ' + membs);
return membs;
}
public void beginning() {
index = 0;
}
public void previous() {
index = index - blockSize;
}
public void next() {
index = index + blockSize;
}
public void end() {
index = totalrecs - math.mod(totalRecs,blockSize);
}
public boolean getprev() {
if(index == 0)
return true;
else
return false;
}
public boolean getnxt() {
if((index + blockSize) > totalRecs)
return true;
else
return false;
}
Please help me regarding this on priority basis.
i try below code as well as but not working
===================
public void getAccount_apex(){
try{
String scheme2=sam.Scheme_Master__c;
strQuery ='SELECT Id,Account__c,Account__r.Name,Account__r.SF_Customer_Code__c,Account__r.SAP_Customer_Code__c, Scheme_Master__c from Scheme_Assign_Master__c where Scheme_Master__c =:scheme2';
System.debug('strQuery@@'+strQuery);
if(totalRecs !=null && totalRecs ==0){
List<Scheme_Assign_Master__c> schemeTemp;
schemeTemp = Database.query(strQuery);
totalRecs = (schemeTemp !=null && schemeTemp.size()>0)?schemeTemp.size():0;
}
strQuery += ' ORDER BY Name ASC, CreatedDate DESC LIMIT :LimitSize OFFSET :OffsetSize';
schemepgList=Database.query(strQuery);
System.debug('schemepgList---->'+schemepgList);
for(Scheme_Assign_Master__c sch:schemepgList){
Wrapschemelist.add(new wrapscheme(sch));
}
}catch(Exception e){
System.debug('exception'+e.getMessage());
System.debug('exception'+e.getLineNumber());
OffsetSize = 0;
getprev();
getnxt();
}
}
public class Wrapscheme {
public Scheme_Assign_Master__c scheme {get;set;}
public Wrapscheme(Scheme_Assign_Master__c pr){
scheme=pr;
}
}
////////////////****** pagination logic *****************///////
public void FirstPage()
{
OffsetSize = 0;
getAccount_apex();
}
public void previous()
{
OffsetSize = (OffsetSize-LimitSize);
getAccount_apex();
}
public void next()
{
OffsetSize = OffsetSize + LimitSize;
getAccount_apex();
}
public void LastPage()
{
OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
System.debug('OffsetSize--'+OffsetSize);
getAccount_apex();
}
public boolean getprev()
{
System.debug('prev'+OffsetSize);
if(OffsetSize == 0){
return true;
}
else {
return false;
}
}
public boolean getnxt()
{
if((OffsetSize + LimitSize) > totalRecs){
return true;
}
else {
return false;
}
}
anyone please help me regarding to display the record using pagination.i want to display the record on button click.getting the error-Unknown property 'AssignScheme.membs'.i am calling the method below button.
vf page
=======
<apex:commandButton styleClass="slds-button slds-button_brand" value="Show Asignment" action="{!getAccount_apex}" onclick="reloadPage()" reRender="outptText">
</apex:commandButton>
<apex:repeat value="{!membs }" var="awl" >
<tr class="slds-hint-parent">
<th scope="row">
<div class="slds-form-element__control">{!awl.scheme.Account__r.Name}</div>
</th>
<td data-label="" class="fromvalue">
<div class="slds-form-element__control">{!awl.scheme.Account__r.SF_Customer_Code__c}</div>
</td>
<td data-label="" class="fromvalue">
<div class="slds-form-element__control">{!awl.scheme.Account__r.SAP_Customer_Code__c}</div>
</td>
<td data-label="">
<apex:commandButton styleClass="slds-button slds-button_destructive" value="Delete" action="{!Remove}" onclick="reloadPage()" >
</apex:commandButton>
</td>
</tr>
</apex:repeat>
</tbody>
apex code
===========
public List<Scheme_Assign_Master__c> getAccount_apex() {
String scheme2=sam.Scheme_Master__c;
List<Scheme_Assign_Master__c> membs =Database.Query('SELECT Id,Account__c,Account__r.Name,Account__r.SF_Customer_Code__c,Account__r.SAP_Customer_Code__c, Scheme_Master__c from Scheme_Assign_Master__c where Scheme_Master__c =:scheme2 LIMIT :blockSize OFFSET :index');
System.debug('Values are ' + membs);
return membs;
}
public void beginning() {
index = 0;
}
public void previous() {
index = index - blockSize;
}
public void next() {
index = index + blockSize;
}
public void end() {
index = totalrecs - math.mod(totalRecs,blockSize);
}
public boolean getprev() {
if(index == 0)
return true;
else
return false;
}
public boolean getnxt() {
if((index + blockSize) > totalRecs)
return true;
else
return false;
}
Please help me regarding this on priority basis.
i try below code as well as but not working
===================
public void getAccount_apex(){
try{
String scheme2=sam.Scheme_Master__c;
strQuery ='SELECT Id,Account__c,Account__r.Name,Account__r.SF_Customer_Code__c,Account__r.SAP_Customer_Code__c, Scheme_Master__c from Scheme_Assign_Master__c where Scheme_Master__c =:scheme2';
System.debug('strQuery@@'+strQuery);
if(totalRecs !=null && totalRecs ==0){
List<Scheme_Assign_Master__c> schemeTemp;
schemeTemp = Database.query(strQuery);
totalRecs = (schemeTemp !=null && schemeTemp.size()>0)?schemeTemp.size():0;
}
strQuery += ' ORDER BY Name ASC, CreatedDate DESC LIMIT :LimitSize OFFSET :OffsetSize';
schemepgList=Database.query(strQuery);
System.debug('schemepgList---->'+schemepgList);
for(Scheme_Assign_Master__c sch:schemepgList){
Wrapschemelist.add(new wrapscheme(sch));
}
}catch(Exception e){
System.debug('exception'+e.getMessage());
System.debug('exception'+e.getLineNumber());
OffsetSize = 0;
getprev();
getnxt();
}
}
public class Wrapscheme {
public Scheme_Assign_Master__c scheme {get;set;}
public Wrapscheme(Scheme_Assign_Master__c pr){
scheme=pr;
}
}
////////////////****** pagination logic *****************///////
public void FirstPage()
{
OffsetSize = 0;
getAccount_apex();
}
public void previous()
{
OffsetSize = (OffsetSize-LimitSize);
getAccount_apex();
}
public void next()
{
OffsetSize = OffsetSize + LimitSize;
getAccount_apex();
}
public void LastPage()
{
OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
System.debug('OffsetSize--'+OffsetSize);
getAccount_apex();
}
public boolean getprev()
{
System.debug('prev'+OffsetSize);
if(OffsetSize == 0){
return true;
}
else {
return false;
}
}
public boolean getnxt()
{
if((OffsetSize + LimitSize) > totalRecs){
return true;
}
else {
return false;
}
}
Greetings!
I would suggest you to capture the debug logs to see the code which is causing the issue.Also,please refer the below blog to know more details on the Offset.
https://developer.salesforce.com/blogs/tech-pubs/2012/06/the-joys-of-soql-pagination.html
Please mark it as best answer if it helps you to fix the issue.
Thank you!
Regards,
Shirisha Pathuri