bogdan / datagrid

Gem to create tables grids with sortable columns and filters
MIT License
1.02k stars 115 forks source link

Datagrid filter integration with bootstrap select #261

Closed jdaprato closed 5 years ago

jdaprato commented 5 years ago

Hello Bogdan,

First of all thanks a lot for your tremendous work very userful and documented ! That being said, I've been trying to integrate bootstrap select (https://developer.snapappointments.com/bootstrap-select/) with your filter system and it worked fine until I tried to add the title attribute. Unfortunately it seems that this attribute is not taken into account, nothing happens. Here's the code: filter(:age_range_id, :enum, :select => proc {AgeRange.all.map {|a| [a.name, a.id]}}, :class => 'form-control selectpicker', :title => "Aucune sélection")

And here's the current render : image

Any help would be appreciated,

bogdan commented 5 years ago

filter options are not automatically passed to a <select> tag. However you can build custom options if you want. Doc: https://github.com/bogdan/datagrid/wiki/Frontend#filter-input-html-options

jdaprato commented 5 years ago

Thanks a lot for your answer. If it can help here exactly the changes I've made: in _form.html.erb: <%= f.datagrid_filter filter, filter.options[:input_options] %> In my devices_grid.rb: filter(:age_range_id, :enum, :select => proc {AgeRange.all.map {|a| [a.name, a.id]}}, :multiple => true, input_options: {title: "Aucune sélection", class: 'form-control selectpicker'})

It works like a charm ! Have a nice day !