TableDnD icon indicating copy to clipboard operation
TableDnD copied to clipboard

Drag and drop of current and next row

Open rn54n opened this issue 9 years ago • 2 comments

Hi,

first of all thank you for TableDnD it's awesome and fast, but I still miss one feautre which would help me a lot in my special case. I have searched now almost all search engines and read a lot of approaches with no success.

What is my problem:

I have a "table". After that I defined a header "thead" and in there I defined my "th". Within tablednd this is not drag or dropable. After that I have a php foreach loop which reads all of my data and writes it into my "tbody" and creates more rows "tr" and so on... The rows can be dragged and dropped easily and very smoothly. But my problem is - I want to drag and drop the current row and the next row together - i can easily give them a unique group tag if necessary.

Additionally I don't want to use nested tables, because I loose the alignment of the columns header!

So far here is my simple code - Is it possible to move both tr's with ID 25 or ID 26?

<table id="myTableToSort_1">
      <thead class="header nodrop">
        <th name="aaa">AAA</th>
        <th name="bbb">BBB</th>
        <th name="ccc">CCC</th>
        <th name="ddd">DDD</th>
      </thead>  
      <tbody>
        <tr id="25">
            <td>values for row 25</td>
            <td>values for row 25</td>
            <td>values for  row 25</td>
            <td>values for  row 25</td>
        </tr>
        <tr id="25">
            <td colspan="4">this row belongs to row 25 and should be moved with row 25</td>
        </tr>
        <tr id="26">
            <td>values for row 26</td>
            <td>values for row 26</td>
            <td>values for row 26</td>
            <td>values for row 26</td>
        </tr>
        <tr id="26">
            <td colspan="4">this row belongs to row 26 and should be moved with row 26</td>
        </tr>
      </tbody>
</table>

Many thanks in advance. Hope someone can help me.

Best Regards Aaren

rn54n avatar Jul 09 '15 16:07 rn54n

Hi,

or is it possible to moving all my tbody's and change that in the jquery.tablednd.js??

<table id="myTableToSort_1">
      <thead class="header nodrop">
        <th name="aaa">AAA</th>
        <th name="bbb">BBB</th>
        <th name="ccc">CCC</th>
        <th name="ddd">DDD</th>
      </thead>  
      <tbody id="25">
        <tr>
            <td>values for row in tbody id 25</td>
            <td>values for row in tbody id 25</td>
            <td>values for  row in tbody id 25</td>
            <td>values for  row in tbody id 25</td>
        </tr>
        <tr>
            <td colspan="4">this row belongs to row 25 and should be moved with tbody id 25</td>
        </tr>
       </tbody>
      <tbody id="26">
        <tr>
            <td>values for row in tbody id 26</td>
            <td>values for row in tbody id 26</td>
            <td>values for row in tbody id 26</td>
            <td>values for row in tbody id 26</td>
        </tr>
        <tr>
            <td colspan="4">this row belongs to row 26 and should be moved with tbody id 26</td>
        </tr>
        </tbody>
</table>

Actually I think going one step up to tbody instead using tr's would do the trick?

Best Regards Aaren

rn54n avatar Jul 09 '15 19:07 rn54n

I finally solved it without using the tablednd anymore. I did it with jquery sortable so far and this works fine. Now I can move two rows together.

rn54n avatar Jul 21 '15 23:07 rn54n