Available in the OSS Version
Tree - Drag and Drop - Multiple Trees
This sample demonstrates how to drag and drop nodes from one igTree control to another.
This sample uses CTP (Community Technical Preview) features. The API and behavior may change when these features are released with full support.
File Manager 1
File Manager 2
This sample is designed for a larger screen size.
On mobile, try rotating your screen, view full size, or email to another device.
Code View
Copy to Clipboard
<!DOCTYPE html> <html> <head> <title></title> <!-- Ignite UI for jQuery Required Combined CSS Files --> <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" /> <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/structure/infragistics.css" rel="stylesheet" /> <style> .containerTree { overflow: auto; width: 100%; } .containerTree h3 { margin-bottom: 5px; } #left { display: inline; float: left; width: 350px; margin-right: 30px; margin-bottom: 10px; } #right { float: left; width: 350px; margin-bottom: 10px; } #firstTree, #secondTree { font-size: 14px; } @media screen and (max-width: 500px) { #left { width: 270px; } #right { width: 270px; clear: both; } } </style> <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script> <!-- Ignite UI for jQuery Required Combined JavaScript Files --> <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.core.js"></script> <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.lob.js"></script> </head> <body> <div class="containerTree"> <div id="left"> <h3>File Manager 1</h3> <!--igTree target element--> <div id="firstTree"></div> </div> <div id="right"> <h3>File Manager 2</h3> <!--igTree target element--> <div id="secondTree"></div> </div> </div> <script src="/data-files/hierarchical-files.js"></script> <script> $(function () { $("#firstTree").igTree({ checkboxMode: 'triState', singleBranchExpand: true, dataSource: $.extend(true, [], files), dataSourceType: 'json', initialExpandDepth: 0, pathSeparator: '.', bindings: { textKey: 'Text', valueKey: 'Value', imageUrlKey: 'ImageUrl', childDataProperty: 'Folder' }, dragAndDrop: true, dragAndDropSettings: { allowDrop: true, customDropValidation: function (element) { // Validates the drop target var valid = true, droppableNode = $(this); if (droppableNode.is('a') && droppableNode.closest('li[data-role=node]').attr('data-value') === 'File') { valid = false; } return valid; } } }); $("#secondTree").igTree({ checkboxMode: 'triState', singleBranchExpand: true, dataSource: $.extend(true, [], files), dataSourceType: 'json', initialExpandDepth: 0, pathSeparator: '.', bindings: { textKey: 'Text', valueKey: 'Value', imageUrlKey: 'ImageUrl', childDataProperty: 'Folder' }, dragAndDrop: true, dragAndDropSettings: { allowDrop: true, customDropValidation: function (element) { // Validates the drop target var valid = true, droppableNode = $(this); if (droppableNode.is('a') && droppableNode.closest('li[data-role=node]').attr('data-value') === 'File') { valid = false; } return valid; } } }); }); </script> </body> </html>
var files = [ { Text: "Computer", Value: "Folder", ImageUrl: "../../images/samples/tree/computer.png", Folder: [ { Text: "Music", Value: "Folder", ImageUrl: "../../images/samples/tree/book.png", Folder: [ { Text: "Y.Malmsteen", Value: "Folder", ImageUrl: "../../images/samples/tree/book.png", Folder: [{ Text: "Making Love", Value: "File", ImageUrl: "../../images/samples/tree/music.png", Folder: "" }, { Text: "Rising Force", Value: "File", ImageUrl: "../../images/samples/tree/music.png", Folder: "" }, { Text: "Fire and Ice", Value: "File", ImageUrl: "../../images/samples/tree/music.png", Folder: "" } ] }, { Text: "WhiteSnake", Value: "Folder", ImageUrl: "../../images/samples/tree/book.png", Folder: [ { Text: "Trouble", Value: "File", ImageUrl: "../../images/samples/tree/music.png", Folder: "" }, { Text: "Bad Boys", Value: "File", ImageUrl: "../../images/samples/tree/music.png", Folder: "" }, { Text: "Is This Love", Value: "File", ImageUrl: "../../images/samples/tree/music.png", Folder: "" } ] }, { Text: "AC/DC", Value: "Folder", ImageUrl: "../../images/samples/tree/book.png", Folder: [ { Text: "ThunderStruck", Value: "File", ImageUrl: "../../images/samples/tree/music.png", Folder: "" }, { Text: "T.N.T.", Value: "File", ImageUrl: "../../images/samples/tree/music.png", Folder: "" }, { Text: "The Jack", Value: "File", ImageUrl: "../../images/samples/tree/music.png", Folder: "" } ] }, { Text: "Rock", Value: "Folder", ImageUrl: "../../images/samples/tree/book.png", Folder: [{ Text: "Bon Jovi - Always", Value: "File", ImageUrl: "../../images/samples/tree/music.png", Folder: "" }] }] }, { Text: "My Documents", Value: "Folder", ImageUrl: "../../images/samples/tree/documents-folder.png", Folder: [ { Text: "2009", Value: "Folder", ImageUrl: "../../images/samples/tree/documents-folder.png", Folder: [ { Text: "Month Report", Value: "File", ImageUrl: "../../images/samples/tree/documents.png", Folder: "" }, { Text: "Year Report", Value: "File", ImageUrl: "../../images/samples/tree/documents.png", Folder: "" } ] }, { Text: "2010", Value: "Folder", ImageUrl: "../../images/samples/tree/documents-folder.png", Folder: [ { Text: "Month Report", Value: "File", ImageUrl: "../../images/samples/tree/documents.png", Folder: "" }, { Text: "Year Report", Value: "File", ImageUrl: "../../images/samples/tree/documents.png", Folder: "" } ] }] }, { Text: "Pictures", Value: "Folder", ImageUrl: "../../images/samples/tree/coins.png", Folder: [ { Text: "BirthDay2009", Value: "Folder", ImageUrl: "../../images/samples/tree/coins.png", Folder: [ { Text: "Picture1", Value: "File", ImageUrl: "../../images/samples/tree/coins_add.png", Folder: "" }, { Text: "Picture2", Value: "File", ImageUrl: "../../images/samples/tree/coins_add.png", Folder: "" }, { Text: "Picture3", Value: "File", ImageUrl: "../../images/samples/tree/coins_add.png", Folder: "" }, { Text: "Picture4", Value: "File", ImageUrl: "../../images/samples/tree/coins_add.png", Folder: "" } ] }, { Text: "BirthDay2010", Value: "Folder", ImageUrl: "../../images/samples/tree/coins.png", Folder: [ { Text: "Picture1", Value: "File", ImageUrl: "../../images/samples/tree/coins_add.png", Folder: "" }, { Text: "Picture2", Value: "File", ImageUrl: "../../images/samples/tree/coins_add.png", Folder: "" }, { Text: "Picture3", Value: "File", ImageUrl: "../../images/samples/tree/coins_add.png", Folder: "" } ] }] }, { Text: "Network", Value: "Folder", ImageUrl: "../../images/samples/tree/door.png", Folder: [ { Text: "Archive", Value: "Folder", ImageUrl: "../../images/samples/tree/door_in.png", Folder: "" }, { Text: "BackUp", Value: "Folder", ImageUrl: "../../images/samples/tree/door_in.png", Folder: "" }, { Text: "FTP", Value: "Folder", ImageUrl: "../../images/samples/tree/door_in.png", Folder: "" } ] }, { Text: "Deleted", Value: "Folder", ImageUrl: "../../images/samples/tree/bin_empty.png", Folder: "" } ] }];