2014-10-17 68 views
0

我试图让tablesorter只显示5个结果为每个页面,而不是默认的10.我在这里看到类似的问题,但解决方案不适合我。Tablesorter寻呼机选项将默认行设置为5

<script> 
$(document).ready(function() { 
    // define pager options 
    var pagerOptions = { 
     // target the pager markup - see the HTML block below 
     container: $(".pager"), size: 5, 
     // output string - default is '{page}/{totalPages}'; possible variables: {page}, {totalPages}, {startRow}, {endRow} and {totalRows} 
     output: '{startRow} - {endRow}/{filteredRows} ({totalRows})', 
     // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty 
     // table row set to a height to compensate; default is false 
     fixedHeight: true, 
     // remove rows from the table to speed up the sort of large tables. 
     // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled. 
     removeRows: false, 
     // go to page selector - select dropdown that sets the current page 
     cssGoto: '.gotoPage' 
    }; 

    $("#Test") 
     .tablesorter({ 
      theme: 'blue', 
      dateFormat: "mmddyy", 
      widgets: ['zebra', 'filter', 'pager', 'columns'], 
      widgetOptions: { 
       // output default: '{page}/{totalPages}' 
       // possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows} 
       pager_output: '{startRow} - {endRow}/{filteredRows} ({totalRows})', // '{page}/{totalPages}' 
       pager_removeRows: false, 

       // include child row content while filtering, if true 
       filter_childRows: true, 
       // class name applied to filter row and each input 
       filter_cssFilter: 'tablesorter-filter', 
       // search from beginning 
       filter_startsWith: false, 
       // Set this option to false to make the searches case sensitive 
       filter_ignoreCase: true 
      } 
     }) 
     .tablesorterPager(pagerOptions); 
}); 
</script> 

我真的很喜欢这方面的帮助。虽然我已经指定了5个,但默认情况下总是10行,当我从分页器下拉菜单中选择它时,它的默认值是5,但它在加载表格时不是默认值。

<select class="gotoPage2" aria-disabled="false"></select> 
     <img class="first disabled" title="First page" alt="First" src="~/Content/images/first.png" tabindex="0" aria-disabled="true" /> 
     <img class="prev disabled" title="Previous page" alt="Prev" src="~/Content/images/prev.png" tabindex="0" aria-disabled="true" /> 
     <span class="pagedisplay"></span> 
     <!-- 

     this can be any element, including an input 

     --> 
     <img class="next" title="Next page" alt="Next" src="~/Content/images/next.png" tabindex="0" aria-disabled="false" /> 
     <img class="last" title="Last page" alt="Last" src="~/Content/images/last.png" tabindex="0" aria-disabled="false" /> 
     <select class="pagesize"> 
      <option selected="selected" value="5">5</option> 
      <option value="10">10</option> 
      <option value="20">20</option> 
      <option value="30">30</option> 
      <option value="40">40</option> 
     </select> 
    </div> 

回答

0

你可能得到的回答前不久,但以防万一 你需要改变你的选择选项,以反映新的寻呼

<select class="pagesize"> 
     <option selected="selected" value="5">5</option> 
     <option value="5">5</option> 
     <option value="10">10</option> 
     <option value="15">15</option> 
     <option value="20">20</option> 
     <option value="25">25</option> 
     <option value="30">30</option> 
</select> 
+0

它看起来就像是在PHP端的问题更多,而不是HTML端 – Chris 2015-01-07 19:20:18