Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7865271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:02:14+00:00 2026-06-03T00:02:14+00:00

My JavaScript code is as below //I have a Json: var jsonRoles = {"roles":

  • 0

My JavaScript code is as below

//I have a Json:

var jsonRoles = {"roles": [
                            {"roleId": "1", "roleName": "role1", "roleDesc": "This is role1"},
                            {"roleId": "2", "roleName": "role2", "roleDesc": "This is role2"},
                            {"roleId": "3", "roleName": "role3", "roleDesc": "This is role3"}
                        ]
                    };

//To get the all role name listed in DND container i used the for loop:

var results="";
                    for(var i=0;i<jsonRoles.roles.length;i++){
                        results += '<div class="dojoDndItem">' + jsonRoles.roles[i].roleName  + '</div>';
                    }

//The two content panes are as below for two blocks for drag and drop

var assignPermissionToUser1 = new dijit.layout.ContentPane({
                        //splitter:true,
                        region: "left",
                        style: "background-color: white;width: 200px; height: 500px",
                        content:'<div>' + '<label>Roles</label>' + '</div>' + '<div dojoType="dojo.dnd.Source" id="rolelistNode" class="container">' + 
                                '<div dojoType="dojo.dnd.Source" class="dojoDndItem movableContainer">' + '</div>' + results +
                                '</div>'       
                    });
                    var assignPermissionToUser2 = new dijit.layout.ContentPane({
                        //splitter:true,
                        region: "right",
                        style: "background-color: white;width: 200px; height: 500px",
                        content:'<div>' + '<label>Users</label>' + '</div>' +'<div dojoType="dojo.dnd.Source" class="container">' +
                                '<div dojoType="dojo.dnd.Source" class="dojoDndItem movableContainer">' + '</div>' +
                                '</div>'            
                    });

//Border Container

            innerBorderContainerAsAccordion = new dijit.layout.BorderContainer({
                id: "innerBorderContainerAsAccordion",
                region: "center",
                style: "background-color: white;width: 175px; height: 550px"
            });

//Set the contents of the border container

    innerBorderContainerAsAccordion.addChild(assignPermissionToUser1);
    innerBorderContainerAsAccordion.addChild(assignPermissionToUser2);

My question is if I drag an element from on DND container to the another, how can it arrange/sort the items by their ID or by alphabet etc?

For example (below images)

Initial states of both container
enter image description here

After drag and drop some items to second DND container
enter image description here

How can I force fully sort the items of second DND container like this:
enter image description here

Can anyone help? Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:02:15+00:00Added an answer on June 3, 2026 at 12:02 am

    Please try this code, and this time its javascript

     function sortList(listId) {
            // Get the ul object
            var oUl = document.getElementById(listId);
            /* Perform a Bubble Sort on the list items */
            for (var i in oUl.childNodes) {
                var x = oUl.childNodes[i];
                for (var j in oUl.childNodes) {
                    var y = oUl.childNodes[j];
                    if ((x.innerText != 'undefined' || y.innerText != 'undefined') && x.innerText > y.innerText) {
                        // Skip if x is already the first list item
                        if (oUl.firstChild != x)
                            oUl.insertBefore(y, x);
                    }
                }
            }
    
        }
    
        /* Define innerText for Mozilla based browsers */
        if ((typeof HTMLElement != 'undefined') && (HTMLElement.prototype.__defineGetter__ != 'undefined')) {
            HTMLElement.prototype.__defineGetter__("innerText", function () {
                var r = this.ownerDocument.createRange();
                r.selectNodeContents(this);
                return r.toString();
            });
    
        }
    
    
        window.onload = function () {
            sortList("ID_of_Your_ul_tag");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this javascript code below that uses jquery, it is suppoed to be
i have a javascript module name SceneModule, see the code snippet below var SceneModule
I have the below code in my jqgrid <script type=text/javascript> jQuery(document).ready(function() { var grid
I have a dialog box, created with the code javascript and HTML generated below.
I've simplified my JavaScript code to the example below; this code is giving me
I have the following JavaScript array of real estate home objects: var json =
Question: The JavaScript code below: records is JSON serialized data. I can access it
I have the code as per below. This retrieves some data to use for
I have the code below. I expected it shows the in JSON format the
I'm have this code below. As you can see I'm trying to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.