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

How can I make a columns dropdown list dependent on another columns selected value?

Open TomTurtle opened this issue 1 year ago • 6 comments

Description

I'm using bootstrapTable and data-filter-control. And I wonder how I can make a columns dropdown list dependent on another columns selected value? An example can be found directly on the examples page https://examples.bootstrap-table.com/#extensions/filter-control.html. For example, when you enter '5' in the column "Item Name" you see only 2 items in the list. But the dropdown menu of the item price shows all prices, not just the 2 different prices of the displayed rows (which I would like).

Example(s)

https://examples.bootstrap-table.com/#extensions/filter-control.html

TomTurtle avatar Mar 22 '23 06:03 TomTurtle

If you want to obtain a second select filter with values dependent on first choice in the first select filter: apply hideUnusedSelectOptions : true as Table Option.

Tried with 1.16 and 1.21.2.

francogiacobbi avatar Mar 24 '23 16:03 francogiacobbi

Great! Thank you very much for your help! :-)

TomTurtle avatar Mar 27 '23 04:03 TomTurtle

Unfortunately I have identified a weak point in this solution... this option hides ALL unused dropdown options, even from the first dropdown. For example when I have a dropdown "Databases" and a drop "Tables" and I select a Database, the dropdown for Database also only shows the selected database (an empty entry), and I can no longer select another database.
Is there a possibility to do the filtering for only for specific columns? Thank you!

TomTurtle avatar Mar 27 '23 07:03 TomTurtle

I believe you must reset your filter

  1. Clicking on first empty entry on first filter or 2. Adding a button to reset all filters.

francogiacobbi avatar Mar 27 '23 07:03 francogiacobbi

yes, this does work. but if there would be a column-specific possibility one would only have to select another database instead of clicking 2 times (1. clear, 2. select)

TomTurtle avatar Mar 27 '23 07:03 TomTurtle

How do I turn on hideUnusedSelectOptions? Is it within the <table></table> tags?

I have multiple dropdown filters, and each one of them has a dependency on the other filers, for example, Country, State, City, etc. If you select country, the state should be filtered by country, and if you select a state, the city dropdown should filtered by the country and the state.

akayueh avatar Feb 07 '24 11:02 akayueh