Saturday, 18 July 2015

Add selected item in multilist at top position

Leave a Comment
In this blog post I am going to explain how to add selected item at top position of the multilist instead of bottom in Sitecore content editor. By default, whenever an item is selected and moved to right side section in the multilist editor then the selected item is added to the bottom of the list in right section. I want to change this behavior so that selected item is added at top position of the list in right section.

To implement this feature we have to modify the 'multilistMoveRight' javascript function in Content Editor.js file. This file exists at \Website\sitecore\shell\Applications\Content Manager folder of website root. Open Content Editor.js file and search for scContentEditor.prototype.multilistMoveRight and modify existing code as below:
scContentEditor.prototype.multilistMoveRight = function (id, allOptions) {
    var all = scForm.browser.getControl(id + "_unselected");
    var selected = scForm.browser.getControl(id + "_selected");

    for (var n = 0; n < all.options.length; n++) {
        var option = all.options[n];

        if (option.selected || allOptions == true) {
            var opt = document.createElement("OPTION");


            opt.innerHTML = option.innerHTML;
            opt.value = option.value;

    this.multilistRemoveSelected(all, allOptions, id + "_all_help");


    //move the last item to the top
    for (var n = selected.options.length - 1; n > 0; n--) {
        var option = selected.options[n];       
        var prev = scForm.browser.getPreviousSibling(option);
        scForm.browser.swapNode(option, prev);

Comments and suggestions are most welcome. Happy coding!


Post a Comment