Requirements
- Display a table with category, group, and item.
- Items must be sortable within a group (but can not move to other groups).
Current Code
I am currently using a large 'ul' with 'li' for rows and 'h3-h5' for columns. Then I style it like a table. I did this because I thought it would make things more flexible than using a proper table. Also browser compatibility is not a major concern. See my current code in jsfiddle. A small html snippet below.
HTML:
<div class="markup-value">
<ul class="category-list ui-sortable">
<li class="category" note_measure_id="62527" measure_category_id="16">
<h3 class="line-heading"></h3>
<li class="group" note_measure_id="62528" measure_group_id="288">
<h4 class="handle"></h4>
jQuery:
$('ul.category-list').sortable({
handle: '.drag-handle',
axis: 'y',
items: 'li.measure',
//update: patientPhoneReorderHandler,
helper: fixDragWidth
});
The problem
The base items can be dragged between groups. I tried to prevent this by wrapping the hierarchy in ul tags. But the table formatting would no longer work as the ul automatically got treated as a table cell instead letting it's children li's be table rows. This would be my ideal method as I would like categories to be reordered maintaining their children and group within categories while maintaining their children. An applicable fork of the original fiddle. Notice the "ul.group-list" in the sample below:
<div class="markup-value">
<ul class="category-list ui-sortable">
<li class="category" note_measure_id="62527" measure_category_id="16">
<h3 class="line-heading"></h3>
<ul class="group-list">
<li class="group" note_measure_id="62528" measure_group_id="288">
<h4 class="handle"></h4>
The solution:
- If their is a method that allows this hierarchy to work with the additional ul tags and still look like a flat table this would be my ideal solution.
- It would also be acceptable to have the html in the flat orientation and somehow limit the draggable area. The list can be quite large so I want to avoid looping through each item or group.