3

I have a lookup combobox whose source is another SharePoint list. By default, this combobox items are sorted by word order but I want to sort this items with another/custom order. How can I do this?

Such as the default view of this combobox is:

EUR    
USD    
TRY

But I want this combobox with this sort:

TRY    
EUR    
USD

My source list order is the same with following:

Currency CurrencySeq

TRY       1
EUR       2
USD       3

1 Answer 1

2

There aren't any server side solutions for doing that unfortunately.

You could check the following solution provided by this post

$(function(){
    var fieldLabel = "LookupField";
    var lookup = $("h3:contains("+ fieldLabel +")").closest("td").next().find("select");
    $(lookup).find("option").sort(function(a,b){
        if(b.innerHTML == 'Test2') return 1;
        return 0;
    }).appendTo($(lookup));
});

Another alternartive, if you are willing to use Infopaths, if I remember well, you can set a sorting on the datasource.

Hope it helps.

1
  • Thank you so much for your help. It helped me and I solved my problem. I did not use JavaScript or JQuery but I found a way at InfoPath as you said. When I wanted to choose a new data source for combobox, I could create a new data connection through InfoPath and choose any column to sort my combobox items.
    – newbie
    Commented Apr 30, 2012 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.