Friday, 31 July 2015

Sort values in Custom Multi Select Picklist - Visual force Page

Hi Friends ,

Here I am giving the post to sort the values in Multi Select Picklist . I am giving the simple technique to sort values using Java Script in VF Pages.

Here is the sample code to include in VF page to sort pick list values,


function sortRightSelect(typeval) {
    selElem = document.getElementById(typeval);
    var tmpAry = new Array();
    for (var i=0;i<selElem.options.length;i++) {
        tmpAry[i] = new Array();
        tmpAry[i][0] = selElem.options[i].text;
        tmpAry[i][1] = selElem.options[i].value;
    }
    tmpAry.sort();
    while (selElem.options.length > 0) {
        selElem.options[0] = null;
    }
    for (var i=0;i<tmpAry.length;i++) {
        var op = new Option(tmpAry[i][0], tmpAry[i][1]);
        selElem.options[i] = op;
    }
    return;
 }

Here is the sample code to call in OnChange function :

sortRightSelect('tehpage:theform:thepb:accright');

Here the highlighted code in red color is the ID value for the PicklIst value from VF page.


Thank you.



1 comment:

  1. Nice post. Oracle is a relational database management system produced by oracle corporation. Nowadays most of the multinational companies used this oracle database for storing and managing their data's and programs.

    salesforce training in Chennai

    ReplyDelete