使用tablesorter jquery进行分页和排序

时间:2013-06-10 09:07:46

标签: javascript jquery ajax

我正在使用tablesorter对动态表进行pag和排序。但它只排序没有分页。这是我的代码,有什么问题?

<script type="text/javascript">
    function loadTable() {     
        $.post(
            "<%=request.getContextPath()%>/Controller", 
            {datepicker: $("#datepicker").val(),month: $("#month").val(), year: $("#year").val()},  
            function(j){
                if(j!=null){
                    var table = "";                     
                    $.each(j, function(key,value) {
                        table += '<tr>';
                        table += '<td>' +value['serviceId'] + '</td>';
                        table += '<td>' +value['commandCode']+ '</td>';
                        table += '<td>' +value['smsUser'] + '</td>';
                        table += '<td>' +value['emsUser'] + '</td>';
                        table += '</tr>';
                    });
                    $("#resultTable tbody").append(table)
                        .tablesorter({widthFixed: true, widgets: ['zebra'], sortLocaleCompare: true, sortList: [0,0]})
                        .tablesorterPager({container: $("#pager"), size: $(".pagesize option:selected").val()});
                }
            }
        );
    }   

选择日期并调用loadTable();

<script type="text/javascript" >
    $(function() {
             $( "#datepicker" ).datepicker({dateFormat: "dd-M-yy" , onSelect: function() {
             $("#month").val($.datepicker.formatDate('mm', $("#datepicker").datepicker('getDate')));
             $("#year").val($.datepicker.formatDate('yy', $("#datepicker").datepicker('getDate')));
             loadTable();
             }
             });

    });
</script>

和我的HTML                                    服务ID             命令代码             总短信用户             总ems用户                                                

0 个答案:

没有答案