JavaScript Grid

Bind to the sort event by type: jqxGrid. Author: http://jqwidgets.com

by talaberf

HTML

<script src="https://jqwidgets.com/public/jqwidgets/jqx-all.js"></script>
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.energyblue.css">
<script src="https://jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/generatedata.js"></script>
<div class="sortable-container">
        <span>Team A</span>
        <div id="sortable1" class="sortable"></div>
    </div>
    <div class="sortable-container">
        <span>Team B</span>
        <div id="sortable2" class="sortable"></div>
    </div>

CSS

<style>
        .sortable {
            margin: 2px;
            padding: 5px;
            width: 200px;
            height:50px;
        }

        .sortable-container{;
            float: left;
            width: 220px;
            height:150px;
            border: blue solid 1px;
        }

        .sortable-container span {
            font-weight: bold;
        }

        .sortable div {
            border-radius: 5px;
            padding: 5px;
            background-color: white;
            color: black;
            cursor: pointer;
            border: 1px solid transparent;
            height:50px;
         }

         .sortable div:hover {
            border: 1px solid #356AA0;
          }
    </style>

JavaScript

$(document).ready(function () {
            var firstNames = ["Nancy", "Andrew", "Janet", "Margaret", "Steven", "Michael", "Robert", "Laura", "Anne"];
            var lastNames = ["Davolio", "Fuller", "Leverling", "Peacock", "Buchanan", "Suyama", "King", "Callahan", "Dodsworth"];
            var titles = ["Sales Representative", "Vice President, Sales", "Sales Representative", "Sales Representative", "Sales Manager", "Sales Representative", "Sales Representative", "Inside Sales Coordinator", "Sales Representative"];

            var sortableList1 = '',
                sortableList2 = '',
                firstNamesLength = firstNames.length,
                firstNamesHalf = Math.floor(firstNamesLength/2);

            for (var i = 0; i < firstNames.length; i++) {
                var element = '<div><table style="min-width: 130px;"><tr><td>' + firstNames[i] + " " + lastNames[i] + '</td></tr><tr><td>' + titles[i] + '</td></tr></table></div>';

                if (i < firstNamesHalf) {
                    sortableList1 = sortableList1 + element;
                } else {
                    sortableList2 = sortableList2 + element;
                }
            }

            $("#sortable1").html(sortableList1);
            $("#sortable2").html(sortableList2);

            $("#sortable1, #sortable2").jqxSortable({
                connectWith: ".sortable",
                opacity: 0.5,
            });
        });