如何从某个表列jquery ui中删除排序

时间:2016-01-04 09:51:38

标签: javascript jquery jquery-ui

我是jquery的新手,我也不是一个程序员。 我试过在谷歌搜索答案,但我找不到答案。

我已经创建了一个表并在列中应用了排序,但我不想让几列可排序,其类名为“.canvas-head”。 这就是我想要的:

<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

2 个答案:

答案 0 :(得分:1)

试试这个:

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

看看这里:jsfiddle.net

参考链接:jquery ui sortable disable for one li item

答案 1 :(得分:0)

您可以为您不想应用sortable的某些表列提供 ID ,而不是.not在选择中

对于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>