AخA
 
1
<html>
2
<head>
3
    <meta charset="utf-8" />
4
    <title>TreeView Drag And Drop</title>
5
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
6
    <script src="https://unpkg.com/gijgo@1.9.14/js/gijgo.min.js" type="text/javascript"></script>
7
    <link href="https://unpkg.com/gijgo@1.9.14/css/gijgo.min.css" rel="stylesheet" type="text/css" />
8
</head>
9
<body>
10
    <div class="container-fluid">
11
        <div id="tree"></div>
12
    </div>
13
    <script type="text/javascript">
14
            $(document).ready(function () {
15
                var tree = $('#tree').tree({
16
                    primaryKey: 'id',
17
                    dataSource: '/Locations/Get',
18
                    dragAndDrop: true
19
                });
20
                tree.on('nodeDrop', function (e, id, parentId, orderNumber) {
21
                    var params = { id: id, parentId: parentId, orderNumber: orderNumber };
22
                    $.ajax({ url: '/Locations/ChangeNodePosition', data: params, method: 'POST' })
23
                        .fail(function () {
24
                            alert('Failed to save.');
25
                        });
26
                });
27
            });
28
    </script>
29
</body>
30
</html>