I am using bootstrap-table for working with data from my database.
I use the pagination features and only send back the number of rows requested by the user using the limit and offset options.
I am also using the table-control extension to allow for easy filtering of the results. However when I use a the select control for filtering with data-filter-control="select" the entries are just those returned within that set of results.
As I apply other filters the list will grow. I would like to use the API and have it preload a list of all possible items from the server for that list to allow for filtering via those options.
While I can send the results back with each filtered set of results, perhaps in a separate element of the JSON, it would likely be best to load this list after the control itself loads as I do not constantly need to be sending that set of data to the control with each filter.
Is this possible? Can I use the API to preload this list with a set of values?
There is an issue on github that seems to describe a similar issue to what I'm having https://github.com/wenzhixin/bootstrap-table/issues/904 and note of a patch, but I'm not sure how to implement that.
I am using bootstrap 3.3.4 from maxcdn.bootstrapcdn.com and I am using bootstrap-table 1.8.1 via cdnjs.cloudflare.com
Edit: I have figured this out after using FireBug to step through the code line by line to figure out if I could do this.
There are two options for supplying data to the filter. Add the attribute data-filter-data to the . You can utilize a "var" or "url" option followed by an underscore (or some other character that gets discarded) and then in the case of "var" pass it an object name, mine looks like this data-filter-data="var_OnlineValues" and utlizes my object var OnlineValues = { "": "", "Started" : "Started", "Submitted" : "Submitted" }. I also have some data on the server that I am returning as JSON. data-filter-data="url_filename.php" and the object returned is a key/value pair.
I hope this helps.
You do not need to modify bootstrap table to make this work. There is a way to set default values to the dropdown select using the
data-filter-data
property of the columns. try adding the following:to the head:
then, add
data-filter-data:'var:filterDefaults'
to the column: