Closed rbdmorgan closed 1 year ago
IMO providing endpoints to automatically load the options out of the box is doomed to have issues with different formats. I wouldn't do it out of the box.
You can try something like this:
class MyGrid
filter(:department, :string, input_options: {class: 'js-department-select'})
end
class DepartmentsSelectController
def index
render json: departments: Department.where("name like '%#{params[:q]}%'").limit(30).map {|d| {text: d.name, id: d.id}
end
$('.js-department-select').select2({
ajax: {
url: 'https://api.github.com/search/repositories',
}
});
Is it possible to wire up a dynamic enum/select filter to something like this:
https://select2.org/data-sources/ajax
Would be useful when you have a proc/query that returns a lot of results.