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>
它看起來就像是在PHP端的問題更多,而不是HTML端 – Chris 2015-01-07 19:20:18