Select2 version 4.0.13
Bootstrap: 4.5.0
Trying display results in a tabular on select2 dropdown.
Able to get the data, but not in tabular format. All the column div display as row each.
Select2 version 4.0.13
Bootstrap: 4.5.0
Trying display results in a tabular on select2 dropdown.
Able to get the data, but not in tabular format. All the column div display as row each.
The easiest way to do this is to supply a custom templateResult function to output each row of the results in a tabular format. You will also need some CSS to make sure that the “cells” of your “rows” are the same size from one “row” to the next. You might also want to create a similar templateSelection function to display the selected item (“row”) in a similar tabular format.
If you want the dropdown to actually display an HTML <table>
, you will need to replace the default ResultsAdapter with your own implementation. Unfortunately there isn’t much documentation on how to write Adapters for Select2. Your best bet is probably to reverse-engineer one starting with the default ResultsAdapter source code, which is available in the Select2 GitHub repository.