Browse Source

Added showJumpToByPages option

zhixin 4 years ago
parent
commit
d4cc0f454f

+ 13 - 1
site/docs/extensions/page-jump-to.md

@@ -31,10 +31,22 @@ toc: true
 
 - **Default:** `false`
 
+### showJumpToByPages
+
+- **attribute:** `data-show-jump-to-by-pages`
+
+- **type:** `Number`
+
+- **Detail:**
+
+   Show 'jump to page' only if the total page is greater than or equal to the set value.
+
+- **Default:** `0`
+
 ## Localizations
 
 ### formatJumpTo
 
 - **Parameter:** `undefined`
 
-- **Default:** `function () { return "GO" }`
+- **Default:** `function () { return "GO" }`

+ 3 - 2
src/extensions/page-jump-to/bootstrap-table-page-jump-to.js

@@ -6,7 +6,8 @@
 const Utils = $.fn.bootstrapTable.utils
 
 $.extend($.fn.bootstrapTable.defaults, {
-  showJumpTo: false
+  showJumpTo: false,
+  showJumpToByPages: 0
 })
 
 $.extend($.fn.bootstrapTable.locales, {
@@ -20,7 +21,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
   initPagination (...args) {
     super.initPagination(...args)
 
-    if (this.options.showJumpTo) {
+    if (this.options.showJumpTo && this.totalPages >= this.options.showJumpToByPages) {
       const $pageGroup = this.$pagination.find('> .pagination')
       let $jumpTo = $pageGroup.find('.page-jump-to')