Skip to content Skip to sidebar Skip to footer

How To Make A Single Element In A Not Sortable (jquery Ui)

I have a table like this Not Sortable (jquery Ui)"
Days Monday Tuesday W

Solution 1:

Make the row headers <th> as they should be and include only <td> elements.

<table>
  <tr class="sortable">
    <th>Days</th>
    <td>Monday</td>
     ...

​$( '​​​​.sortable' ).sortable({
    items: 'td'
});​​​​​

Demo: http://jsfiddle.net/Xugru/


Solution 2:

You can use the cancel option for this:

$('.sortable').sortable({
    cancel: 'td:first'
});

Here's docs.


Solution 3:

<table>
  <tr class="sortable">
    <td>Days</td>
    <td>Monday</td>
    <td>Tuesday</td>
    <td>Wednesday</td>
    <td>Thursday</td>
    <td>Friday</td>
    <td>Saturday</td>
  </tr>
  <tr class="sortable">
    <td>Works</td>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    <td>5</td>
    <td>6</td>
  </tr>
</table>

Let's make the column id not to be sortable.

$(".sortable").sortable({
 items: "td:not(:first)"
});

That's all. All you need is to excludethe first td in items.

Have a great day


Post a Comment for "How To Make A Single

Element In A