bogdan / datagrid

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

How to use Array as data source #259

Closed mikedalpee closed 4 years ago

mikedalpee commented 5 years ago

Your wiki indicates this is possible, but there are no examples. Would you mind providing an example of how to use an Array for the grid's scope?

bogdan commented 5 years ago

Here is a use case from my project https://gist.github.com/540979fbf03bd96960e6415f55fdd123 This grid queries the metadata about MySQL tables and represents them in a nice filtrable and sortable way.

The difference with the Array scope compared to ORM is that you have to filter the data in memory using typical array related methods select and reject.

Also make sure that filtering and pagination in ruby will not blow up your application memory.