0

所以我有一个表设置,我试图对包含整数的列进行排序,但是它没有正确排序。更改学习组列上的数字然后单击标题对其进行排序,您会看到它没有正确按升序或降序排序..

http://jsfiddle.net/2mLr4/1/

HTML

<table id="mytable" class="tablesorter">
<thead>
    <tr> 
    <th>Status</th> 
    <th>Participant Name</th> 
    <th>Reminder Alerts</th>
    <th>E-mail</th> 
    <th>Learning Group</th>
    </tr> 
</thead>
     <tbody>
         <tr>
         <td class="check">i</td>
         <td>Joe Smith <span>Has not started filling out his forms.</span> </td>
         <td> Empty </td>
         <td><button class="clean-gray logout" name="">Remind Now</button> </td>

        <td>
        <div class="learning_selecter">
        <span>3</span>
        <select class="learning_group_num">
        <option value="lg_1">1</option>
        <option value="lg_2">2</option>
        <option value="lg_3">3</option>
        <option value="lg_4">4</option>
        <option value="lg_5">5</option>
        </select>
        </div>  
        </td>
        </tr>

         <tr>
         <td class="check">i</td>
         <td>Joe Smith <span>Has not started filling out his forms.</span> </td>
         <td> Empty </td>
         <td><button class="clean-gray logout" name="">Remind Now</button> </td>

        <td>
        <div class="learning_selecter">
        <span>4</span>
        <select class="learning_group_num">
        <option value="lg_1">1</option>
        <option value="lg_2">2</option>
        <option value="lg_3">3</option>
        <option value="lg_4">4</option>
        <option value="lg_5">5</option>
        </select>
        </div>  
        </td>
        </tr>

        <tr>
         <td class="check">i</td>
         <td>Joe Smith <span>Has not started filling out his forms.</span> </td>
         <td> Empty </td>
         <td><button class="clean-gray logout" name="">Remind Now</button> </td>

        <td>
        <div class="learning_selecter">
        <span>5</span>
        <select class="learning_group_num">
        <option value="lg_1">1</option>
        <option value="lg_2">2</option>
        <option value="lg_3">3</option>
        <option value="lg_4">4</option>
        <option value="lg_5">5</option>
        </select>
        </div>  
        </td>
        </tr>



         <tr>
         <td class="check">i</td>
         <td>Joe Smith <span>Has not started filling out his forms.</span> </td>
         <td> Empty </td>
         <td><button class="clean-gray logout" name="">Remind Now</button> </td>

        <td>
        <div class="learning_selecter">
        <span>2</span>
        <select class="learning_group_num">
        <option value="lg_1">1</option>
        <option value="lg_2">2</option>
        <option value="lg_3">3</option>
        <option value="lg_4">4</option>
        <option value="lg_5">5</option>
        </select>
        </div>  
        </td>
        </tr>

            </tbody>
            </table>
4

1 回答 1

1

原因是因为(我想是为了速度)tablesorter 有效地缓存了表中的值。当您更新它们时,tablesorter 不知道更改并继续根据旧值对它们进行排序。

我有一个快速的谷歌,发现你可以用它来让 tablesorter 知道你已经更新了一些东西:

$("#mytable")
        .trigger('update')
        .trigger('sorton', [sorting]);

这是一个jsfiddle

于 2013-03-01T08:55:31.467 回答