Browse Source

feat (toolbar extension): add server sidePagination support

zhixin 7 years ago
parent
commit
ea5610e18f
1 changed files with 19 additions and 8 deletions
  1. 19 8
      src/extensions/toolbar/bootstrap-table-toolbar.js

+ 19 - 8
src/extensions/toolbar/bootstrap-table-toolbar.js

@@ -125,14 +125,23 @@
         $(`#avdSearchModalContent_${o.idTable}`).append(this.createFormAvd().join(''))
         $(`#avdSearchModalContent_${o.idTable}`).append(this.createFormAvd().join(''))
 
 
         $(`#${o.idForm}`).off('keyup blur', 'input').on('keyup blur', 'input', e => {
         $(`#${o.idForm}`).off('keyup blur', 'input').on('keyup blur', 'input', e => {
-          clearTimeout(timeoutId)
-          timeoutId = setTimeout(() => {
+          if (o.sidePagination === 'server') {
             this.onColumnAdvancedSearch(e)
             this.onColumnAdvancedSearch(e)
-          }, o.searchTimeOut)
+          } else {
+            clearTimeout(timeoutId)
+            timeoutId = setTimeout(() => {
+              this.onColumnAdvancedSearch(e)
+            }, o.searchTimeOut)
+          }
         })
         })
 
 
         $(`#btnCloseAvd_${o.idTable}`).click(() => {
         $(`#btnCloseAvd_${o.idTable}`).click(() => {
           $(`#avdSearchModal_${o.idTable}`).modal('hide')
           $(`#avdSearchModal_${o.idTable}`).modal('hide')
+          if (o.sidePagination === 'server') {
+            this.options.pageNumber = 1
+            this.updatePagination()
+            this.trigger('column-advanced-search', this.filterColumnsPartial)
+          }
         })
         })
 
 
         $(`#avdSearchModal_${o.idTable}`).modal()
         $(`#avdSearchModal_${o.idTable}`).modal()
@@ -166,7 +175,7 @@
     initSearch () {
     initSearch () {
       super.initSearch()
       super.initSearch()
 
 
-      if (!this.options.advancedSearch) {
+      if (!this.options.advancedSearch || this.options.sidePagination === 'server') {
         return
         return
       }
       }
 
 
@@ -204,10 +213,12 @@
         delete this.filterColumnsPartial[$field]
         delete this.filterColumnsPartial[$field]
       }
       }
 
 
-      this.options.pageNumber = 1
-      this.onSearch(e)
-      this.updatePagination()
-      this.trigger('column-advanced-search', $field, text)
+      if (this.options.sidePagination !== 'server') {
+        this.options.pageNumber = 1
+        this.onSearch(e)
+        this.updatePagination()
+        this.trigger('column-advanced-search', $field, text)
+      }
     }
     }
   }
   }
 })(jQuery)
 })(jQuery)