Activity Forums Salesforce® Discussions Sorting based on column value in salesforce

  • Bhavesh

    Member
    January 3, 2017 at 2:40 pm

    If you have apex page like:

     

    <apex:commandButton value="Sort Table" action="{!sortMethod}" reRender="pgblcktbl"/>

    you are callilng sortMethod:

     

    ublic void sortMethod(){
    if(selectedField == 'Name')
    accList = [select name,accountnumber,annualrevenue from account where id IN:accList order by Name limit 100 ];
    else if(selectedField == 'AccountNumber')
    accList = [select name,accountnumber,annualrevenue from account where id IN:accList order by AccountNumber limit 100 ];
    else if(selectedField == 'Annualrevenue')
    accList = [select name,accountnumber,annualrevenue from account where id IN:accList order by Annualrevenue desc limit 100 ];
    }

     

    Something like this you can do that

  • Kumar

    Member
    January 4, 2017 at 5:52 am

    Thank you so much! This really helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos