123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /**
- * @author: Dennis Hernández
- * @webSite: http://djhvscf.github.io/Blog
- * @version: v2.0.0
- */
- const isInit = that => that.$el.data('resizableColumns') !== undefined
- const initResizable = that => {
- if (that.options.resizable && !that.options.cardView && !isInit(that)) {
- that.$el.resizableColumns()
- }
- }
- const destroy = that => {
- if (isInit(that)) {
- that.$el.data('resizableColumns').destroy()
- }
- }
- const reInitResizable = that => {
- destroy(that)
- initResizable(that)
- }
- $.extend($.fn.bootstrapTable.defaults, {
- resizable: false
- })
- const BootstrapTable = $.fn.bootstrapTable.Constructor
- const _initBody = BootstrapTable.prototype.initBody
- const _toggleView = BootstrapTable.prototype.toggleView
- const _resetView = BootstrapTable.prototype.resetView
- BootstrapTable.prototype.initBody = function (...args) {
- const that = this
- _initBody.apply(this, Array.prototype.slice.apply(args))
- that.$el
- .off('column-switch.bs.table, page-change.bs.table')
- .on('column-switch.bs.table, page-change.bs.table', () => {
- reInitResizable(that)
- })
- }
- BootstrapTable.prototype.toggleView = function (...args) {
- _toggleView.apply(this, Array.prototype.slice.apply(args))
- if (this.options.resizable && this.options.cardView) {
- // Destroy the plugin
- destroy(this)
- }
- }
- BootstrapTable.prototype.resetView = function (...args) {
- const that = this
- _resetView.apply(this, Array.prototype.slice.apply(args))
- if (this.options.resizable) {
- // because in fitHeader function, we use setTimeout(func, 100);
- setTimeout(() => {
- initResizable(that)
- }, 100)
- }
- }
|