Asp.net mvc 4 在实施tablesorter 2.17.1(或最新版本)时需要帮助

Asp.net mvc 4 在实施tablesorter 2.17.1(或最新版本)时需要帮助,asp.net-mvc-4,tablesorter,Asp.net Mvc 4,Tablesorter,有人能帮我得到一个MVC应用程序的工作样本吗?对于如何将最新的tablesorter插件应用到我的MVC示例中,我有点困惑 $('table').trigger('sortReset') 在下面的teble中 <table class="tablesorter"> <thead> <tr> <th>AlphaNumeric Sort</th> <th>

有人能帮我得到一个MVC应用程序的工作样本吗?对于如何将最新的tablesorter插件应用到我的MVC示例中,我有点困惑

$('table').trigger('sortReset')
在下面的teble中

<table class="tablesorter">
    <thead>
        <tr>
            <th>AlphaNumeric Sort</th>
            <th>Currency</th>
            <th>Alphabetical</th>
            <th>Sites</th>
        </tr>
    </thead>
    <tbody>
        <tr><td>abc 123</td><td>&#163;10,40</td><td>Koala</td><td>http://www.google.com</td></tr>
        <tr><td>abc 1</td><td>&#163;234,10</td><td>Ox</td><td>http://www.yahoo.com</td></tr>
        <tr><td>abc 9</td><td>&#163;10,33</td><td>Girafee</td><td>http://www.facebook.com</td></tr>
        <tr><td>zyx 24</td><td>&#163;10</td><td>Bison</td><td>http://www.whitehouse.gov/</td></tr>
        <tr><td>abc 11</td><td>&#163;3,20</td><td>Chimp</td><td>http://www.ucla.edu/</td></tr>
        <tr><td>abc 2</td><td>&#163;56,10</td><td>Elephant</td><td>http://www.wikipedia.org/</td></tr>
        <tr><td>abc 9</td><td>&#163;3,20</td><td>Lion</td><td>http://www.nytimes.com/</td></tr>
        <tr><td>ABC 10</td><td>&#163;87,00</td><td>Zebra</td><td>http://www.google.com</td></tr>
        <tr><td>zyx 1</td><td>&#163;99,90</td><td>Koala</td><td>http://www.mit.edu/</td></tr>
        <tr><td>zyx 12</td><td>&#163;234,10</td><td>Llama</td><td>http://www.nasa.gov/</td></tr>
    </tbody>
</table>

字母数字排序
通货
按字母顺序排列的
地点
abc 123和163;104000oalahttp://www.google.com
abc 1和163;234,10Oxhttp://www.yahoo.com
abc 9和163;10,33Girafeehttp://www.facebook.com
zyx 24£;10Bisonhttp://www.whitehouse.gov/
abc 11和163;3,20摄氏度himphttp://www.ucla.edu/
abc 2和163;56,10Elephanthttp://www.wikipedia.org/
abc 9和163;3,20Lionhttp://www.nytimes.com/
ABC 10和163;8700Zebrahttp://www.google.com
zyx163;99,90Koalahttp://www.mit.edu/
zyx 12£;234,10Llamahttp://www.nasa.gov/
另外,我所指的js和css文件如下

<head>
<meta charset="utf-8">
<title>Basic Tablesorter Demo</title>


<link href="~/Content/jq.css" rel="stylesheet" />

<link href="~/Content/theme.default.css" rel="stylesheet" />

<script src="~/Scripts/jquery-latest.min.js"></script>
<script src="~/Scripts/jquery-ui-1.8.24.min.js"></script>
<script src="~/Scripts/jquery.tablesorter.min.js"></script>
<script src="~/Scripts/jquery.tablesorter.widgets.min.js"></script>

<script>
    $(function () {
        $('.tablesorter').tablesorter({
            widgets: ['zebra', 'columns'],
            usNumberFormat: false,
            sortReset: true,
            sortRestart: true
        });
    });

</script>

基本表排序器演示
$(函数(){
$('.tablesorter').tablesorter({
小部件:['zebra','columns'],
usNumberFormat:false,
真的,
sortRestart:对
});
});

不确定为什么我不能让它工作..它为tablesorter()发出了一个类似“UncaughtTypeError:undefined不是函数”的错误

注意:我了解到这种重置功能在插件2.4.7之后可用

非常感谢你的帮助


谢谢

您需要在页面上添加一个元素,允许用户单击重置排序。在中,我将使用一个按钮:

<button type="button" class="reset">Reset Sort</button>

或者,用户可以使用Ctrl+左键单击任何标题单元格来重置排序。可以使用。

Thank@Mottie更改钥匙。您的示例在JSFIDLE中运行良好。但我仍然面临的问题是,它没有将tablesorter主题应用于html表。不过,我发现它适用于tablesorter 2.0.0。Ohhhhh..我找到了问题所在。我曾经两次引用Jquery.1.8.1.min.js。一个在_Layout.cshtml中,另一个在页面本身。我现在删除了其中一个,并且工作得很好……感谢@Mottie…还有@Mottie,我们不能使用sortList{}进行多列排序吗?对于这个版本的tablesorter,我们需要使用sortOn{}吗?您能在JSFIDLE的示例中更新它吗?我使用了'sortList=[[0,0],[1,1]]$(“table”).trigger(“sorton”,“sortList”);`它成功了
$(function () {
    $('.tablesorter').tablesorter({
        widgets: ['zebra', 'columns'],
        usNumberFormat: false,
        sortReset: true,
        sortRestart: true
    });

    // make button reset the sort
    $('.reset').click(function(){
        $('.tablesorter').trigger('sortReset');
    });

});