【问题标题】:tablesorter column with text and integer带有文本和整数的表排序器列
【发布时间】:2015-04-08 03:01:59
【问题描述】:

demo 模型列未正确排序。只是因为列中有一个整数。有人说我可以使用复杂的文本提取,但我不知道如何。谁能帮我?您的大力帮助会有所帮助

$(document).ready(function() { 

// call the tablesorter plugin 
$("table").tablesorter({ 
    // define a custom text extraction function 
    textExtraction: function(node) { 
        // extract data from markup and return it  
        return node.childNodes[0].childNodes[0].innerHTML; 
    } 
}); 
});

【问题讨论】:

    标签: javascript jquery web integer tablesorter


    【解决方案1】:

    发生的情况是86 是列中的第一个单元格。所以解析器的自动检测认为这是一个数字列。要修复它,只需将列解析器设置为文本。最简单的方法是在标题中添加一个“sorter-text”类。

    由于插件只查看thead中列的最后一个单元格,您需要将类添加到“模型”单元格(demo)。

    <thead>
        <tr>
            <td class='tablehover2 sorter-false' rowspan=2><a href='http://www.toyota.com.hk/cars/new_cars/index.aspx' target='_blank'> Toyota </a>
            </td>
            <td class='tablehover2 sorter-false'><a >Full Model List & Specifications</a>
            </td>
            <td class='tablehover2 sorter-false'><a> Price List</a>
            </td>
        </tr>
        <tr>
            <!-- the parsers are set by the class names in this row -->
            <td class='tablehover sorter-text'>Model</td>
            <td class='tablehover'>Price</td>
        </tr>
    </thead>
    

    无需设置textExtraction函数:

    $('#tablesorter').tablesorter({
        theme: 'blackice'
    });
    

    【讨论】:

    • 知道了!感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-02
    • 2013-07-17
    • 2011-01-08
    • 2016-09-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多