Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting height option breaks the Filter Control extension #7171

Open
kilgorejd opened this issue Jan 30, 2024 · 8 comments · May be fixed by #7445
Open

setting height option breaks the Filter Control extension #7171

kilgorejd opened this issue Jan 30, 2024 · 8 comments · May be fixed by #7445
Labels
Bug Issues which are marked as Bug filter-control Issues for the filter-control extension.

Comments

@kilgorejd
Copy link

Bootstraptable version(s) affected

1.22.1

Description

When enabling the height option on my bootstrap-table, the extension for column filters, Filter Control, no longer works, specifically for the 'select' filterControl using filterData like "var:SOMEVAR". The dropdowns are no longer populated. Removing the height option makes everything happy again.

Example(s)

No response

Possible Solutions

No response

Additional Context

No response

@kilgorejd kilgorejd added the Bug Issues which are marked as Bug label Jan 30, 2024
@wenzhixin wenzhixin added the filter-control Issues for the filter-control extension. label Mar 15, 2024
@wenzhixin
Copy link
Owner

Please provide an Online Example to show your problem. Thanks!

@hiephm
Copy link

hiephm commented Apr 18, 2024

I can confirm this problem happen when setting both 'data-height' and data-mobile-responsive="true".
When setting either 'data-height' or data-mobile-responsive="true", the filter control displays normally.

Related issues: #4869, #5013, #5129

@jayaddison
Copy link

The bug requires filter-control and mobile extensions to be loaded, and is replicable on 1.22.1 (as-reported) and 1.23.2 (latest).

(a minimal example suitable for use on the live editor is included in this GitHub-details snippet)
<table
  id="table"
  data-url="json/data1.json"
  data-filter-control="true"
  data-height="400"
  data-mobile-responsive="true"
  data-show-search-clear-button="true">
  <thead>
    <tr>
      <th data-field="id">ID</th>
      <th data-field="name"
          data-filter-control="input">Item Name</th>
      <th data-field="price"
          data-filter-control="select"
          data-filter-data="var:priceFilter">Item Price</th>
    </tr>
  </thead>
</table>

<script>
  $(function() {
    $('#table').bootstrapTable()
  });
  var priceFilter = ["$0", "$1"];
</script>

The cause of the bug appears to be inconsistent results from this getControlContainer function.

In particular, when getControlContainer is called after the filter controls have already been initialized (that._initialized is true), then the selected table (CSS selector query '.fixed-table-header table thead') -- although it does exist in the DOM -- appears to have empty contents.

That causes a subsequent call to getOptionsFromSelectControl to fail (and emit a JavaScript error), because no selectControl is found in the empty table.

I'm not sure yet what is wrong:

  • Should the empty table in the header be created? (is it used for something?)
  • Is the CSS selector .fixed-table-header table thead incorrect?

Continuing to investigate.

@jayaddison
Copy link

I'm not sure yet what is wrong:

  • Should the empty table in the header be created? (is it used for something?)

  • Is the CSS selector .fixed-table-header table thead incorrect?

These could be related to the fact that fixed header mode is enabled automatically when the data-height attribute is set, as explained in the FAQ: https://bootstrap-table.com/docs/faq/

However: the filter columns controls do not seem to exist within the fixed header - is that inconsistency the problem?

@jayaddison
Copy link

Also: why does this only happen when the data-mobile-responsive attribute is set using the mobile extension?

@jayaddison
Copy link

Additional findings:

  • If the page is resized from 'card view' (responsive mode) to 'full view' (desktop / large display mode), then the filters reappear.
  • However, resizing within 'full view' (changing the viewport dimensions, but without causing the table to change into responsive display mode) causes the filters to disappear again.

Credit: #6471 (comment) where @mausol identified the first of these behaviours.

@jayaddison
Copy link

I'm not completely confident that the fix is correct, but I have opened a pull request that resolves this problem for an example case in #7445.

@jayaddison
Copy link

@kilgorejd @hiephm are you able to confirm whether the code example at https://live.bootstrap-table.com/code/jayaddison/18021 accurately replicates this problem? If possible: thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues which are marked as Bug filter-control Issues for the filter-control extension.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants