Releases: bogdan/datagrid
Releases · bogdan/datagrid
v2.0.1
Changes
- Fixed
search
field type support #330
class UsersGrid < Datagrid::Base
scope { User }
filter(
:query, :string, input_options: { type: "search" }
) do |value, scope|
scope.magic_search(value)
end
end
Renders filter as:
<input type="search" name="users_grid[query]" id="users_grid_query"/>
- Added support for
default_filter_options
and added lambda support fordefault_column_options
#333 by @tmikoss.
class UsersGrid < Datagrid::Base
scope { User }
self.default_column_options = -> (column) {
{header: I18n.t("datagrid.keywords.#{column.name}")}
}
self.default_filter_options = -> (filter) {
{
header: I18n.t("datagrid.keywords.user.#{filter.name}"),
input_options: filter.type == :string ? {type: "textarea"} : {},
}
}
filter(:first_name, :string)
filter(:last_name, :string)
column(:first_name)
column(:last_name)
end
v2.0.0
Datagrid Version 2
Datagrid v1 was released on Sep 19 2013 - more than 10 years ago.
A lot of changes in best practices and available technology
had happened during this period.
These include:
- HTML5
- Ruby endless ranges
- Ruby beginless ranges
- Put a star if you didn't know they were introduced one version apart.
- Ruby Keyword Arguments
- Modular CSS
- Rails Engines
It caused the library to be designed without support of those technologies
or their implementation to be suboptimal because of backward compatibility.
Version 2 addresses all that evolution.
API changes
- Ruby endless ranges for range filters.
- Use Hash instead of Array for multiparameter attributes.
- Remove
column[url]
option. - Inherit
Datagrid::Base
instead ofinclude Datagrid
. ApplicationGrid
is recommended base class instead ofBaseGrid
.
Frontend Changes
- Use
form_with
instead ofform_for
. - Deprecated
datagrid_order_for
- Modern modular CSS classes.
- HTML5 input types: number, date, datetime-local.
- Native Rails Engines:
- while supported, the library was not initially designed for it.
- HTML5 data attributes
- Use
column[tag_options]
option instead ofcolumn[class]
. - Consistent
label[for]
andinput[id]
for range filters. - Updated app/views/datagrid/enum_checkboxes
- Introduced
datagrid.filters.range.separator
localization - Remove SASS dependency
- Replace
rake datagrid:copy_partials
withrails g datagrid:views