-1

I'm new to jquery and I'm not a programer either. I've tried searching for the answer on google but I just couldn't find the answer.

I have created a table and applied sorting in columns but i dont want to make few columns sortable which has class named ".canvas-head". This is what i am trying:

<script>
$(function () {
$('#sorting').sorttable({
    placeholder: 'placeholder',
    helperCells: ':not(.footerrow td)'
}).disableSelection();

  function reset(){
     $(".canvas-head").sorttable('disable');
   }
   $('.canvas-head').bind('click',reset);
});
</script>

<table id="sorting">
            <tbody>
                <tr class="headerrow ui-sortable">
                    <th class="ui-resizable tac"><div class="ui-resizable">First Year Corn <br>Non Limited N, High Pop(1)</div></th>
                  <th class="canvas-head">Canvas</th>
                    <th class="ui-resizable tac"><div class="ui-resizable">First Year Corn <br>Non Limited N, High Pop(2)</div></th>
                </tr>
                <tr>
<td>one</td>
<td>Two</td>
<td>three</td>
</tr>
</tbody>
</table>

Working example

Praveen
  • 1,772
  • 3
  • 24
  • 42
  • `sorttable`..? really..? Please take sometime, proof read your question and check whether the code works without obvious syntax errors before posting questions... – T J Jan 05 '16 at 07:37
  • Possible duplicate of [How to exclude an element from sortable list being dragged?](http://stackoverflow.com/questions/13885665/how-to-exclude-an-element-from-sortable-list-being-dragged) – T J Jan 05 '16 at 07:43

2 Answers2

1

Try this:

items: "td:not(.canvas-head)"

Take a look here : jsfiddle.net

reference link : jquery ui sortable disable for one li item

Community
  • 1
  • 1
Budianto IP
  • 1,118
  • 1
  • 13
  • 27
0

You can give a class or id for the certain table columns for which you dont want to apply sortable and than you can use .not in selection

For Eg:

$(function() {
      $('#list').sortable({items: '> li:not(.pin)'});
});

<ul id="list">
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
    <li>Four</li>
    <li class="pin">Five</li>
</ul>
Amar Singh
  • 5,464
  • 2
  • 26
  • 55