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

  • Kumar

    Member
    January 3, 2017 at 2:05 pm

    Hi everyone,

    How can I implement sorting in a table based on a column in the table? Any guidance or working example is appreciated.

    Thanks

  • 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.

Viewing 1 - 3 of 3 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos