tablesorter 页面不需要刷新情况下的js 神器

参考链接   https://mottie.github.io/tablesorter/docs/example-css-highlighting.html

                https://mottie.github.io/tablesorter/docs/


备注:

tablesorter 将bootstrap的 .table-hover类 导致鼠标触发hover事件  却没有相应的样式被匹配  

解决方案 :

 在table 加上类 .focus-highlight  并且设置样式

/* bootstrap highlight works */
table.focus-highlight, table.focus-highlight tbody > tr > td,
/* override zebra styling */
table.hover-highlight tbody tr.even > th,
table.hover-highlight tbody tr.even > td,
table.hover-highlight tbody tr.odd > th,
table.hover-highlight tbody tr.odd > td,
table.focus-highlight tbody tr.even > th,
table.focus-highlight tbody tr.even > td,
table.focus-highlight tbody tr.odd > th,
table.focus-highlight tbody tr.odd > td {
background: transparent;
}



实际操作:

a. 下载  jquery.tablesorter.min.js,   tablesorter-theme/style.css   并且在页面引入

        b.   

常用的设置

var setting = {

            headers : {0:{ sorter: false}}, // 频闭第1列
            1 : {sorter:"integer"}, // 索引从0开始
            2 : {sorter:"integer"}, // 第3列按照整数排列
            3 : {sorter:"integer"},
            4 : {sorter:"integer"},
            sortList : [[1,1],[3,0]] // 设置默认排序  第2列倒序,第4列正序
        };


eg:

<!DOCTYPE html>
<html>
<head>
    <include file="Common@Public/head" />
    <script type="text/javascript" src="__JS__jquery.tablesorter.min.js"></script>
    <link rel="stylesheet" href="__CSS__tablesorter-theme/style.css">
</head>
<body>
<include file="Common@Public/dhb_info" />
<include file="Common@Public/header" />
<div class="container">
    <div id="breadcrumb_box">
        <include file="Common@Public/nav" />
    </div>
</div>

<div class="container">
    <div class="panel panel-default">
        <table class="table table-hover table-bordered tablesorter focus-highlight" id="table_show">
            <thead>
            <tr>
                <th>field1</th>
                <th>field2</th>
                <th>field3</th>
                <th>field4</th>
                <th>field5</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach($show_list as $crawler=>$show) {?>
            <tr>
                <td><?= $crawler; ?></td>
                <td><?= $show['total']; ?></td>
                <td><?= $show['login_status']; ?></td>
                <td><?= $show['status']; ?></td>
                <td><?= $show['status_report']; ?></td>
            </tr>
            <?php }?>
            </tbody>
        </table>
    </div>
</div>
<script type="text/javascript">
    $(function () {

        var setting = {
            headers : {0:{ sorter: false}}, // 频闭第1            1 : {sorter:"integer"}, // 索引从0开始
            2 : {sorter:"integer"}, // 3列按照整数排列
            3 : {sorter:"integer"},
            4 : {sorter:"integer"},
            sortList : [[1,1],[3,0]] // 设置默认排序  第2列倒序,4列正序
        };
        $("#table_show").tablesorter(setting);
    })
</script>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值