使用jquery和tablesorter只对一列进行排序 [英] Sort only one column with jquery and tablesorter

查看:316
本文介绍了使用jquery和tablesorter只对一列进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在使用jquery tablesorter和tablesorter过滤器。我的问题是,我希望我的过滤器只过滤一列。现在它过滤所有列。您可以在此处查看我的网站: http://tinyurl.com/3j38vye

At the moment im using jquery tablesorter and tablesorter filter. My problem is that i want that my filter would filter only one column. Now its filtering all columns. You can see my site here: http://tinyurl.com/3j38vye

现在它过滤所有列,我只想过滤Lainasumma列。你能说出为什么它的排序量不合适吗?

Now its filtering all colums and i'd like to filter only "Lainasumma" column. Could you also say why its not sorting amounts properly?

推荐答案

你看过documentation 这是一个示例,说明如何禁用某些使用tablesorter的列。您可以传递一个标题对象,您可以在其中指定禁用哪些列。

Did you look at the documentation? Here is an example of how you would disable some columns that use tablesorter. You can pass a headers object in which you can specify which columns are disabled.

另一种方法是添加 class ={sorter:false}到您要禁用排序的单元格。

An alternate method is to add class="{sorter: false}" to the cells on which you want to disable the sorting.

您可以使用 $。tablesorter.addParser()方法来定义自定义排序(请参阅上面的jsFiddle示例) 。

You can use $.tablesorter.addParser() method to define custom sorting (see the jsFiddle example above).

$(document).ready(function() {
    $.tablesorter.addParser({
        id: 'custom_sort_function',
        is: function(s) {
            return false;
        },
        format: function(s) {
            // the € symbol causes the tablesorter to treat the value as a string
            // remove it and let the tablesorter treat it as numeric
            // use /\u20AC/ instead of /€/ if regex does not work as expected
            return s.replace(/€/, '');
        },
        type: 'numeric'
    });
    $("#pikavipit").tablesorter({
        headers: {
            0: {
                sorter: false
            },
            1: {
                sorter: false
            },
            2: {
                sorter: 'custom_sort_function'
            },
            3: {
                sorter: false
            },
            4: {
                sorter: false
            },
            5: {
                sorter: false
            },
            6: {
                sorter: false
            },
            7: {
                sorter: false
            },
            8: {
                sorter: false
            }
        }
    });
});

这篇关于使用jquery和tablesorter只对一列进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆