简体   繁体   English

JQuery表排序问题 - 跳过列禁用第一次鼠标单击

[英]JQuery Table Sort issue - Skipping column disables first mouse click

I have created a basic table in js fiddle. 我用js小提琴创建了一个基本表。 I am using the datatable sorter function, however if you click along the headers, or click a header, skip one and click another, it seems to ignore the first mouse-click. 我正在使用数据表分类器功能,但是如果您单击标题,或单击标题,跳过一个并单击另一个,它似乎忽略第一次鼠标单击。 (To replicate the issue click on Confirmation Period, then ABN, then back to Confirmation Period) (要复制问题,请单击确认期,然后单击ABN,然后返回到确认期)

Any thoughts? 有什么想法吗?

<table id="tableSort" class="tableSort" cellspacing="0" style="margin-top:20px;margin-left:10px;">
<thead>
    <tr>
        <th>Confirmation Period</th>
        <th>Legal/Entity Name</th>
        <th>ABN</th>
        <th>Business/Trading Name</th>
        <th>Status</th>
    </tr>
</thead>
<tr>
    <td>1</td>
    <td>a</td>
    <td>34</td>
    <td>78</td>
    <td>b</td>
</tr>
<tr>
    <td>2</td>
    <td>c</td>
    <td>100</td>
    <td>90</td>
    <td>g</td>
</tr>

and the JS... 和JS ......

$(document).ready(function () {
    $('#tableSort').dataTable({
        "searching": false,
            "paging": false,
            "info": false
});

}); });

jsfiddle: http://jsfiddle.net/wcdg3ddL/ jsfiddle: http//jsfiddle.net/wcdg3ddL/

The table is actually sorting as expected. 该表实际上按预期排序。 There are two reasons why it looks like the columns aren't sorting: 看起来列没有排序的原因有两个:

  1. You have insufficient rows in your table to assess whether or not sorting is working. 您的表中没有足够的行来评估排序是否有效。 Add few more rows of data and you should see what I mean. 添加更多行数据,您应该看到我的意思。
  2. Because you've removed the arrows from the header row with your custom styling you cannot accurately gauge how the sorting is behaving. 由于您已使用自定义样式从标题行中删除了箭头,因此无法准确衡量排序的行为方式。 If you add in the default CSS styling you can see the direction in which a column is being sorted. 如果添加默认的CSS样式,则可以看到列的排序方向。

Here is a fiddle where I have added sufficient rows so that the columns appear to be sorting correctly. 这是一个小提琴 ,我添加了足够的行,以便列看起来正确排序。

I just added more rows to your fiddle: 我刚给你的小提琴添加了更多行:

<tr>
        <td>1</td>
        <td>a</td>
        <td>34</td>
        <td>78</td>
        <td>b</td>
</tr>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM