bootstrap-table icon indicating copy to clipboard operation
bootstrap-table copied to clipboard

Sticky header attempts to render, while not initialized

Open vever001 opened this issue 1 year ago • 1 comments

Bootstraptable version(s) affected

1.22.2

Description

When combining the filter-control and sticky-header, we get an error in console. See https://live.bootstrap-table.com/code/vever001/17062

Uncaught TypeError: Cannot read properties of undefined (reading 'offset')
    at p.value (bootstrap-table-sticky-header.min.js:10:20501)
    at p.value (bootstrap-table-sticky-header.min.js:10:19051)
    at bootstrap-table-filter-control.min.js:10:49522

It seems the onColumnSearch gets called from here, and calls this.renderStickyHeader() without checking if sticky headers is enabled on the table or not (while the sticky header may not have been initialized).

Example(s)

https://live.bootstrap-table.com/code/vever001/17062

Possible Solutions

Add a check for this.options.stickyHeader ?

Additional Context

FWIW we made a temp workaround as follows for now:

$.BootstrapTable = class extends $.BootstrapTable {
  renderStickyHeader () {
    if (this.options.stickyHeader) {
      super.renderStickyHeader();
    }
  }
}

vever001 avatar Feb 05 '24 17:02 vever001

A PR is welcome.

wenzhixin avatar Mar 15 '24 00:03 wenzhixin

Just created the PR which fixes the issue for me at least.

dhirtzbruch avatar Jul 10 '24 09:07 dhirtzbruch