{"id":16740,"date":"2018-02-11T00:36:32","date_gmt":"2018-02-11T00:36:32","guid":{"rendered":"https:\/\/www.muvipa.com.mx\/registro\/assets\/js\/aci-tree\/acitree-drag-drop-sorting-demo-a-treeview-control-with-jquery\/"},"modified":"2018-02-11T00:36:32","modified_gmt":"2018-02-11T00:36:32","slug":"acitree-drag-drop-sorting-demo-a-treeview-control-with-jquery","status":"publish","type":"page","link":"https:\/\/www.muvipa.com.mx\/?page_id=16740","title":{"rendered":"aciTree drag &amp; drop sorting demo &#8211; A treeview control with jQuery"},"content":{"rendered":"<div>\n<p>The <i>sortable<\/i> extension is using the aciSortable plugin, the available callback init options and the options parameter of the event handler<br \/>\n                receives the properties as defined by aciSortable (see the docs). aciTree adds a few extra events on top of aciSortable so we can handle<br \/>\n                with ease the drag start and check for a valid drop target. In this way we can limit what items can be dragged and where they can be dropped.<\/p>\n<p>For dragging tree items out of the tree &#8211; check <a href=\"aciTree-drag-outside.html\" target=\"_blank\" title=\"Dragging items outside tree\" rel=\"noopener noreferrer\">this<\/a> demo.<\/p>\n<p>See the examples below for what can be done by responding to only two events: <b>beforedrag<\/b> and <b>checkdrop<\/b>.<\/p>\n<p>Note: you can also implement your own <b>options.sortDrag<\/b> and <b>options.sortValid<\/b><br \/>\n                callbacks to set the helper (the element that follows the mouse pointer when in drag) the way you want.<br \/>\n                For the default implementation &#8211; check the source code of the <i>sortable<\/i> extension.<\/p>\n<p>The default implementation (<b>options.sortable<\/b> needs to be active), you can drag &amp; drop items anywhere, before or after another one,<br \/>\n                set as a child of a leaf node (it will be transformed in a inode by default), the parent can be changed:<\/p>\n<div id=\"tree1\" class=\"aciTree\">\n<div>\n                    <a style=\"font-size:10px\" href=\"\/source\/php\/niceJson.php?file=source\/aciTree\/json\/checkbox.json\" title=\"See the JSON data\" target=\"_blank\" rel=\"noopener noreferrer\">see the JSON behind this tree<\/a><br \/>\n                    <br \/>The easy way to find a car that&#8217;s right for you<\/div>\n<\/div>\n<div class=\"log\">Tree Log&#8230; <a class=\"clear_log\" style=\"font-size:10px\" href=\"#\" title=\"Clear the LOG\" target=\"_blank\" rel=\"noopener noreferrer\">clear log<\/a><\/p>\n<div \/><\/div>\n<div style=\"clear:both\" \/>\n<p><\/p>\n<p>Limit the number of newly created tree levels to only #3 (we wont be able to add more than #3 levels deep but still be able to sort<br \/>\n                existing items in more than #3 levels deep):<\/p>\n<div id=\"tree2\" class=\"aciTree\">\n<div>\n                    <a style=\"font-size:10px\" href=\"\/source\/php\/niceJson.php?file=source\/aciTree\/json\/checkbox.json\" title=\"See the JSON data\" target=\"_blank\" rel=\"noopener noreferrer\">see the JSON behind this tree<\/a><br \/>\n                    <br \/>The easy way to find a car that&#8217;s right for you<\/div>\n<\/div>\n<div class=\"log\">Tree Log&#8230; <a class=\"clear_log\" style=\"font-size:10px\" href=\"#\" title=\"Clear the LOG\" target=\"_blank\" rel=\"noopener noreferrer\">clear log<\/a><\/p>\n<div \/><\/div>\n<div style=\"clear:both\" \/>\n<p>            = 2) {<br \/>\n                                        \/\/ mark the drop target as invalid<br \/>\n                                        return false;<br \/>\n                                    }<br \/>\n                                } else {<br \/>\n                                    if (options.before === null) {<br \/>\n                                        \/\/ container creation is disabled for levels &gt;= #3<br \/>\n                                        var target = api.itemFrom(options.hover);<br \/>\n                                        if (api.level(target) &gt;= 2) {<br \/>\n                                            \/\/ mark the drop target as invalid<br \/>\n                                            return false;<br \/>\n                                        }<br \/>\n                                    }<br \/>\n                                }<br \/>\n                                break;<br \/>\n                        }<br \/>\n                    });<\/p>\n<p>                    \/\/ init the tree<br \/>\n                    $(&#8216;#tree2&#8217;).aciTree({<br \/>\n                        ajax: {<br \/>\n                            url: &#8216;json\/checkbox-radio-button.json&#8217;<br \/>\n                        },<br \/>\n                        sortable: true<br \/>\n                    });<\/p>\n<p>                });<\/p>\n<p>            ]]&gt;<\/p>\n<p><\/p>\n<p>Limit the items that can be dragged around to just leaf items:<\/p>\n<div id=\"tree3\" class=\"aciTree\">\n<div>\n                    <a style=\"font-size:10px\" href=\"\/source\/php\/niceJson.php?file=source\/aciTree\/json\/checkbox.json\" title=\"See the JSON data\" target=\"_blank\" rel=\"noopener noreferrer\">see the JSON behind this tree<\/a><br \/>\n                    <br \/>The easy way to find a car that&#8217;s right for you<\/div>\n<\/div>\n<div class=\"log\">Tree Log&#8230; <a class=\"clear_log\" style=\"font-size:10px\" href=\"#\" title=\"Clear the LOG\" target=\"_blank\" rel=\"noopener noreferrer\">clear log<\/a><\/p>\n<div \/><\/div>\n<div style=\"clear:both\" \/>\n<p><\/p>\n<p>Items can be dragged around only inside the same parent (items can&#8217;t change parent):<\/p>\n<div id=\"tree4\" class=\"aciTree\">\n<div>\n                    <a style=\"font-size:10px\" href=\"\/source\/php\/niceJson.php?file=source\/aciTree\/json\/checkbox.json\" title=\"See the JSON data\" target=\"_blank\" rel=\"noopener noreferrer\">see the JSON behind this tree<\/a><br \/>\n                    <br \/>The easy way to find a car that&#8217;s right for you<\/div>\n<\/div>\n<div class=\"log\">Tree Log&#8230; <a class=\"clear_log\" style=\"font-size:10px\" href=\"#\" title=\"Clear the LOG\" target=\"_blank\" rel=\"noopener noreferrer\">clear log<\/a><\/p>\n<div \/><\/div>\n<div style=\"clear:both\" \/>\n<p>            &lt;![CDATA[<\/p>\n<p>                $(function() {<\/p>\n<p>                    \/\/ write to log<br \/>\n                    $(&#039;[id^=tree]&#039;).on(&#039;acitree&#039;, function(event, api, item, eventName, options) {<br \/>\n                        var log = $(this).next(&#039;.log&#039;).find(&#039;div&#039;);<br \/>\n                        if (api.isItem(item)) {<br \/>\n                            log.prepend(&#039;<\/p>\n<p>&#8216; + eventName + &#8216; [&#8216; + api.getId(item) + &#8216;]&#8217;);<br \/>\n                        } else {<br \/>\n                            log.prepend(&#8216;<\/p>\n<p>&#8216; + eventName + &#8216; [tree]&#8217;);<br \/>\n                        }<br \/>\n                    });<\/p>\n<p>                    $(&#8216;.clear_log&#8217;).click(function() {<br \/>\n                        $(this).closest(&#8216;.log&#8217;).find(&#8216;div&#8217;).html(\u00bb);<br \/>\n                        return false;<br \/>\n                    });<\/p>\n<p>                });<\/p>\n<p>            ]]&gt;<\/p><\/div>\n<p>        &lt;![CDATA[<\/p>\n<p>            $(function() {<\/p>\n<p>                $(&#039;script.code&#039;).each(function() {<br \/>\n                    $(this).before(&#039;<\/p>\n<div style=\"clear:both;margin:10px 0 10px 0\">\n<pre style=\"padding:20px;border:1px dashed #000;background:#f6f6f6\">');<br \/>\n                    $(this).prev('div').find('pre').text($(this).html());<br \/>\n                });<\/p>\n<p>            });<\/p>\n<p>        ]]&gt;<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>A demo to show you how aciTree can be used with aciSortable, check the plugin page to see all the functions exposed by the API<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":16738,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-16740","page","type-page","status-publish","hentry","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>aciTree drag &amp; drop sorting demo - A treeview control with jQuery - Museo Virtual de Pachuca<\/title>\n<meta name=\"description\" content=\"Conoce m\u00e1s sobre la Ciudad de Pachuca a trav\u00e9s del museo virtual de Pachuca, descubre las galer\u00edas, juegos y articulos que tenemos para ti.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.muvipa.com.mx\/?page_id=16740\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"aciTree drag &amp; drop sorting demo - A treeview control with jQuery - Museo Virtual de Pachuca\" \/>\n<meta property=\"og:description\" content=\"Conoce m\u00e1s sobre la Ciudad de Pachuca a trav\u00e9s del museo virtual de Pachuca, descubre las galer\u00edas, juegos y articulos que tenemos para ti.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.muvipa.com.mx\/?page_id=16740\" \/>\n<meta property=\"og:site_name\" content=\"Museo Virtual de Pachuca\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/museovirtualpachuca\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@MUSEOMUVIPA\" \/>\n<meta name=\"twitter:label1\" content=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.muvipa.com.mx\\\/?page_id=16740\",\"url\":\"https:\\\/\\\/www.muvipa.com.mx\\\/?page_id=16740\",\"name\":\"aciTree drag &amp; drop sorting demo - A treeview control with jQuery - Museo Virtual de Pachuca\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.muvipa.com.mx\\\/#website\"},\"datePublished\":\"2018-02-11T00:36:32+00:00\",\"description\":\"Conoce m\u00e1s sobre la Ciudad de Pachuca a trav\u00e9s del museo virtual de Pachuca, descubre las galer\u00edas, juegos y articulos que tenemos para ti.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.muvipa.com.mx\\\/?page_id=16740#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.muvipa.com.mx\\\/?page_id=16740\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.muvipa.com.mx\\\/?page_id=16740#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\\\/\\\/www.muvipa.com.mx\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Registro\",\"item\":\"https:\\\/\\\/www.muvipa.com.mx\\\/?page_id=16721\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Assets\",\"item\":\"https:\\\/\\\/www.muvipa.com.mx\\\/?page_id=16731\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Js\",\"item\":\"https:\\\/\\\/www.muvipa.com.mx\\\/?page_id=16737\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Aci Tree\",\"item\":\"https:\\\/\\\/www.muvipa.com.mx\\\/?page_id=16738\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"aciTree drag &amp; drop sorting demo &#8211; A treeview control with jQuery\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.muvipa.com.mx\\\/#website\",\"url\":\"https:\\\/\\\/www.muvipa.com.mx\\\/\",\"name\":\"MUVIPA\",\"description\":\"Museo Virtual de Pachuca\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.muvipa.com.mx\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.muvipa.com.mx\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.muvipa.com.mx\\\/#organization\",\"name\":\"Museo Virtual de Pachuca\",\"url\":\"https:\\\/\\\/www.muvipa.com.mx\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/www.muvipa.com.mx\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.muvipa.com.mx\\\/wp-content\\\/uploads\\\/2018\\\/09\\\/cropped-principal.jpg\",\"contentUrl\":\"https:\\\/\\\/www.muvipa.com.mx\\\/wp-content\\\/uploads\\\/2018\\\/09\\\/cropped-principal.jpg\",\"width\":512,\"height\":512,\"caption\":\"Museo Virtual de Pachuca\"},\"image\":{\"@id\":\"https:\\\/\\\/www.muvipa.com.mx\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/museovirtualpachuca\\\/\",\"https:\\\/\\\/x.com\\\/MUSEOMUVIPA\",\"https:\\\/\\\/www.instagram.com\\\/muvipa\\\/\",\"https:\\\/\\\/www.pinterest.com.mx\\\/holamuvipa\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCG-A1s9_Q6fGShym1BHj6Hg\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"aciTree drag &amp; drop sorting demo - A treeview control with jQuery - Museo Virtual de Pachuca","description":"Conoce m\u00e1s sobre la Ciudad de Pachuca a trav\u00e9s del museo virtual de Pachuca, descubre las galer\u00edas, juegos y articulos que tenemos para ti.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.muvipa.com.mx\/?page_id=16740","og_locale":"es_ES","og_type":"article","og_title":"aciTree drag &amp; drop sorting demo - A treeview control with jQuery - Museo Virtual de Pachuca","og_description":"Conoce m\u00e1s sobre la Ciudad de Pachuca a trav\u00e9s del museo virtual de Pachuca, descubre las galer\u00edas, juegos y articulos que tenemos para ti.","og_url":"https:\/\/www.muvipa.com.mx\/?page_id=16740","og_site_name":"Museo Virtual de Pachuca","article_publisher":"https:\/\/www.facebook.com\/museovirtualpachuca\/","twitter_card":"summary_large_image","twitter_site":"@MUSEOMUVIPA","twitter_misc":{"Tiempo de lectura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.muvipa.com.mx\/?page_id=16740","url":"https:\/\/www.muvipa.com.mx\/?page_id=16740","name":"aciTree drag &amp; drop sorting demo - A treeview control with jQuery - Museo Virtual de Pachuca","isPartOf":{"@id":"https:\/\/www.muvipa.com.mx\/#website"},"datePublished":"2018-02-11T00:36:32+00:00","description":"Conoce m\u00e1s sobre la Ciudad de Pachuca a trav\u00e9s del museo virtual de Pachuca, descubre las galer\u00edas, juegos y articulos que tenemos para ti.","breadcrumb":{"@id":"https:\/\/www.muvipa.com.mx\/?page_id=16740#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.muvipa.com.mx\/?page_id=16740"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.muvipa.com.mx\/?page_id=16740#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/www.muvipa.com.mx\/"},{"@type":"ListItem","position":2,"name":"Registro","item":"https:\/\/www.muvipa.com.mx\/?page_id=16721"},{"@type":"ListItem","position":3,"name":"Assets","item":"https:\/\/www.muvipa.com.mx\/?page_id=16731"},{"@type":"ListItem","position":4,"name":"Js","item":"https:\/\/www.muvipa.com.mx\/?page_id=16737"},{"@type":"ListItem","position":5,"name":"Aci Tree","item":"https:\/\/www.muvipa.com.mx\/?page_id=16738"},{"@type":"ListItem","position":6,"name":"aciTree drag &amp; drop sorting demo &#8211; A treeview control with jQuery"}]},{"@type":"WebSite","@id":"https:\/\/www.muvipa.com.mx\/#website","url":"https:\/\/www.muvipa.com.mx\/","name":"MUVIPA","description":"Museo Virtual de Pachuca","publisher":{"@id":"https:\/\/www.muvipa.com.mx\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.muvipa.com.mx\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/www.muvipa.com.mx\/#organization","name":"Museo Virtual de Pachuca","url":"https:\/\/www.muvipa.com.mx\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.muvipa.com.mx\/#\/schema\/logo\/image\/","url":"https:\/\/www.muvipa.com.mx\/wp-content\/uploads\/2018\/09\/cropped-principal.jpg","contentUrl":"https:\/\/www.muvipa.com.mx\/wp-content\/uploads\/2018\/09\/cropped-principal.jpg","width":512,"height":512,"caption":"Museo Virtual de Pachuca"},"image":{"@id":"https:\/\/www.muvipa.com.mx\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/museovirtualpachuca\/","https:\/\/x.com\/MUSEOMUVIPA","https:\/\/www.instagram.com\/muvipa\/","https:\/\/www.pinterest.com.mx\/holamuvipa\/","https:\/\/www.youtube.com\/channel\/UCG-A1s9_Q6fGShym1BHj6Hg"]}]}},"brizy_media":[],"builder_content":"","_links":{"self":[{"href":"https:\/\/www.muvipa.com.mx\/index.php?rest_route=\/wp\/v2\/pages\/16740","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.muvipa.com.mx\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.muvipa.com.mx\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.muvipa.com.mx\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.muvipa.com.mx\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16740"}],"version-history":[{"count":0,"href":"https:\/\/www.muvipa.com.mx\/index.php?rest_route=\/wp\/v2\/pages\/16740\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.muvipa.com.mx\/index.php?rest_route=\/wp\/v2\/pages\/16738"}],"wp:attachment":[{"href":"https:\/\/www.muvipa.com.mx\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}