hd20086996 2016-08-31 06:51 采纳率: 0%
浏览 978
已结题

Jquery插件sortElements排序问题

图片说明
图片说明
求大神帮忙,table表格用插件sortElements排序,但是table有一列是用了rowspan,合并了几行,然后排序就乱了,不知道该怎么办 ,代码如下:

     <table id="requests" style="border-collapse: collapse;font-size: 14px;line-height: 115%;text-align:right;max-width: 100%;table-layout: fixed;border-spacing:0" border="1" >
<tr>
<th class="th_color">域名</th>
<th class="th_color">日期</th>
<th class="th_color" id="all_num">询盘总数<span class="glyphicon glyphicon-resize-vertical"></th>
<th class="th_color" id="todb_num">入库操作总数<span class="glyphicon glyphicon-resize-vertical"></th>
<th class="th_color" id="normal_num">实际入库总数<span class="glyphicon glyphicon-resize-vertical"></th>
<th class="th_color" id="1_num">过滤邮件数<span class="glyphicon glyphicon-resize-vertical"></th>
<th class="th_color" id="2_num">格式错误邮件数<span class="glyphicon glyphicon-resize-vertical"></th>
<th class="th_color" id="3_num">缺失地址邮件数<span class="glyphicon glyphicon-resize-vertical"></span></th>
<th class="th_color" id="4_num">ip过滤数<span class="glyphicon glyphicon-resize-vertical"></span></th>
<th class="th_color" id="percent">入库统计%<span class="glyphicon glyphicon-resize-vertical"></span></th>
<th class="th_color"></th>
</tr>
<?
$weeks=array('日','一','二','三','四','五','六');
?>
<?foreach($reg->web_reqs as $key => $web_reqs){?>
   <?$domain=str_replace(".","_",$key); ?>
    <tr>
      <td class="td1" id="domain_<?=$domain?>" rowspan="<?=count($web_reqs)?>"><?=$key?></td>
<!--                    </tr>-->
<!--                    --><?//$num=0;?>
<!--                    <tr>-->
                    <?foreach($web_reqs as $date => $web_req){?>
<!--                        --><?//if($num!=0){?>
<!--                            <tr>-->
<!--                        --><?//}?>
                        <?$week=$weeks[date('w',  strtotime($date))];?>
                        <td class="td1"><a href="javascript:void(0);" onclick='get_spiders("<?=$key?>","<?=$date?>",<?=$web_req['all_requests']?>)'><?=$date?></a>(<?=$week?>)</td>
                        <td class="td1"><?=$web_req['all_requests']?></td>
                        <td class="td1"><?=$web_req['todb_requests']?></td>
                        <td class="td1"><?=$web_req['normal_requests']?></td>
                        <td class="td1"><?=$web_req['all_status1_nums']?></td>
                        <td class="td1"><?=$web_req['all_status2_nums']?></td>
                        <td class="td1"><?=$web_req['all_status3_nums']?></td>
                        <td class="td1"><?=$web_req['all_status4_nums']?></td>
                        <td class="td1"><?=sprintf("%.2f",($web_req['normal_requests']/$web_req['all_requests'])*100)?>%</td>
                        <?if(empty($reg->domain)){?>
                            <td class="td1">
                                <a href="/index.php?r=adminStatistic/inquiry&starttime=<?=date("Y-m-d",strtotime('-7 days',strtotime($reg->to)));?>&endtime=<?=$reg->to?>&domain=<?=$key?>&subm=查询"><button id="go" onclick="go()" type="button">详细</button> </a>
                            </td>
                    <?}else{?>
                         <td style="width: 120px;">
                       <a href="/index.php?r=adminStatistic/inquiry"><button id="back" onclick="back()" type="button">返回</button> </a>
                     </td>
                 <?}?>
               </tr>
           <?$num++;}?>
        <?}?>
</table>
                     <script>
            var table = $('#requests');
            $('#all_num,#todb_num,#normal_num,#1_num,#2_num,#3_num,#4_num,#percent')
                .each(function(){
                    var th = $(this),
                        thIndex = th.index(),
                        inverse = false;
                    th.click(function(){
                        table.find('td.td1').filter(function(){
                            return $(this).index() === thIndex;
                        }).sortElements(function(a, b){
                            return parseFloat($.text([a])) > parseFloat($.text([b])) ?
                                inverse ? -1 : 1
                                : inverse ? 1 : -1;
                        }, function(){
                            return this.parentNode;
                        });
                        inverse = !inverse;
                    });
                });
            $(function(){
                    $("input[name='starttime']").prop("disabled","");
                    $("input[name='endtime']").prop("disabled","");
                }
            );
        </script>
  • 写回答

1条回答 默认 最新

  • Go 旅城通票 2016-08-31 07:44
    关注

    有合并数据行的,最好是自己写排序功能,没有那么全面的支持合并行排序的插件

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条