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
Ashish Kumar YadavAshish Kumar Yadav 

how to delete the row in pagination

Hello Team,

I want to delete the row in table.please help me regarding this.
User-added image

// Remove logic not working
// Code For Remove Account using Delete Icon.
    public PageReference Remove(){
     rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
        System.debug('rowIndex'+rowIndex);
        membs.remove(rowIndex);
        return null;
    }

//getting the record properly

public List<Scheme_Assign_Master__c> getAccounts() {  
      totalRecs = [select count() from Scheme_Assign_Master__c];
      String scheme2=sam.Scheme_Master__c;
       membs=new list<Scheme_Assign_Master__c>();
       membs =[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 :LimitSize offset :OffsetSize]; 
        System.debug('Values are ' + membs);  
        return null;  
  
    }      
    ////////////////******   pagination logic *****************///////
    public void FirstPage()
    {
        OffsetSize = 0;
        getAccounts();
        
    }
    public void previous()
    {
        OffsetSize = (OffsetSize-LimitSize);
        getAccounts();
        
    }
    public void next()
    {
        OffsetSize =( OffsetSize + LimitSize);
        getAccounts();
        
    }
    public void LastPage()
    {
        OffsetSize = totalrecs - math.mod(totalRecs,LimitSize);
        System.debug('OffsetSize--'+OffsetSize);
        getAccounts();
        
    }
    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;
        }
    }   

   
AnudeepAnudeep (Salesforce Developers) 
Hi Ashish, 

Can you please try removing the field being retrieved from the SOQL query that you want to delete and let me know if it makes any difference? 
 
membs=new list<Scheme_Assign_Master__c>();
       membs =[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 :LimitSize offset :OffsetSize];

 
Ashish Kumar YadavAshish Kumar Yadav
Not working.
AnudeepAnudeep (Salesforce Developers) 
Please review this post where a similar issue is discussed
Ashish Kumar YadavAshish Kumar Yadav
can you please make changes in my code.

 public PageReference Remove(){
     rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
        System.debug('rowIndex'+rowIndex);
        membs.remove(rowIndex);
        return null;
    }