Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo UI sortable table

I'm having problems getting Kendo UI sortable to work on a table.

Code:

<table class="table table-bordered table-striped" id="test-table">
<tr>
    <th colspan="2">Headline</th>           
</tr>       
<tr>
     <td>Test 1</td>
     <td>A</td>
</tr>
<tr>
     <td>Test 2</td>
     <td>B</td>
</tr>
</table>
<script>
    $(function())
      $("#test-table").kendoSortable();
</script>

When I try to sort it looks like I'm only dragging one td-tag, and no sortable what so ever.

like image 637
Lasse Edsvik Avatar asked Aug 24 '26 04:08

Lasse Edsvik


1 Answers

You should apply also a filter to kendoSortable to point to tr.

  <div id="wrapper">
    <table class="table table-bordered table-striped" id="test-table">
        <thead>
            <tr>
                <th colspan="2">Headline</th>           
            </tr>
        </thead>
        <tbody>
            <tr>
                 <td>Test 1</td>
                 <td>A</td>
            </tr>
            <tr>
                 <td>Test 2</td>
                 <td>B</td>
            </tr>
        </tbody>
    </table>
</div>

<script>
    $("#test-table").kendoSortable({
         container: $("#wrapper"),
         filter: ">tbody >tr"
    });
</script>
like image 72
calinaadi Avatar answered Aug 26 '26 18:08

calinaadi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!