Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Okay so I found this plugin: <a href="http://ludo.cubicphuse.nl/jquery-plugins/treeTable/doc/index.html#example-1" rel="nofollow noreferrer">http://ludo.cubicphuse.nl/jquery-plugins/treeTable/doc/index.html#example-1</a></p> <p>This uses tables and allows it to be nested.</p> <p>Now I just need to sort it and post submit the table elements with a parent id so i can save it to the database.</p> <p>I hope this helps someone else.</p> <p>so this is what i came up with. I don't want more then 2 levels ( only parent and childs ) so i changed it to let parents only accept childs, and not made parents draggable.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;link href="jquery.treeTable.css" rel="stylesheet" type="text/css" /&gt; &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="jquery-ui.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="jquery.treeTable.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $("#dragndrop").treeTable(); // Drag &amp; Drop Code $("#dragndrop .child").draggable({ helper: "clone", opacity: .75, refreshPositions: true, // Performance? revert: "invalid", revertDuration: 300, scroll: true } ); $("#dragndrop .parent").each(function() { $($(this).parents("tr")[0]).droppable({ accept: ".child", drop: function(e, ui) { $($(ui.draggable).parents("tr")[0]).appendBranchTo(this); setNewParent($($(ui.draggable).parents("tr")[0]).attr("id"), $(this).attr("id")); }, hoverClass: "accept", over: function(e, ui) { if(this.id != $(ui.draggable.parents("tr")[0]).id &amp;&amp; !$(this).is(".expanded")) { $(this).expand(); } } }); }); function setNewParent(child, parent) { // do ajax call here alert(child); alert(parent); } }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;table id="dragndrop"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Title&lt;/th&gt; &lt;th&gt;Size&lt;/th&gt; &lt;th&gt;Kind&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr id="node-1"&gt; &lt;td&gt;&lt;span class="parent"&gt;CHANGELOG&lt;/span&gt;&lt;/td&gt; &lt;td&gt;4 KB&lt;/td&gt; &lt;td&gt;Parent&lt;/td&gt; &lt;/tr&gt; &lt;tr id="node-3" class="child-of-node-1"&gt; &lt;td&gt;&lt;span class="child"&gt;images&lt;/span&gt;&lt;/td&gt; &lt;td&gt;--&lt;/td&gt; &lt;td&gt;child&lt;/td&gt; &lt;/tr&gt; &lt;tr id="node-2"&gt; &lt;td&gt;&lt;span class="parent"&gt;doc&lt;/span&gt;&lt;/td&gt; &lt;td&gt;--&lt;/td&gt; &lt;td&gt;Parent&lt;/td&gt; &lt;/tr&gt; &lt;tr id="node-4" class="child-of-node-2"&gt; &lt;td&gt;&lt;span class="child"&gt;bg-table-thead.png&lt;/span&gt;&lt;/td&gt; &lt;td&gt;52 KB&lt;/td&gt; &lt;td&gt;child&lt;/td&gt; &lt;/tr&gt; &lt;tr id="node-5" class="child-of-node-2"&gt; &lt;td&gt;&lt;span class="child"&gt;folder.png&lt;/span&gt;&lt;/td&gt; &lt;td&gt;4 KB&lt;/td&gt; &lt;td&gt;child&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/body&gt; </code></pre> <p></p> <p>To make the whole table sortable you can use jQuery's <code>.sortable()</code> function, but I left that out of here to make it more clear.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload