bogdan / datagrid

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

Feature - Datagrid with ActiveResource? #263

Closed jonmchan closed 4 years ago

jonmchan commented 5 years ago

Datagrid supports activerecord - how difficult would it to be to use datagrid with active resource? Has anyone had any experience with this?

https://github.com/rails/activeresource

bogdan commented 5 years ago

It will be hard because activeresource doesn't support any kind of chained finding methods like where(..).where(...).where(...). Datagrid expects this as a core feature to anything it can support.

However there is a hacky way to support activeresource with a constructions like this:


class MyGrid
  scope { [] }
  dynamic do
    scope do
       ActiveResourceModel.find(:all, params: attributes.slice(:one, :two))
    end
  end

  filter(:one, dummy: true)
  filter(:two, dummy: true)
end