All Projects → bogdan → Datagrid

bogdan / Datagrid

Licence: mit
Gem to create tables grids with sortable columns and filters

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Datagrid

Algoliasearch Rails
AlgoliaSearch integration to your favorite ORM
Stars: ✭ 352 (-61.78%)
Mutual labels:  activerecord, mongoid, rails, gem
Graphql devise
GraphQL interface on top devise_token_auth
Stars: ✭ 100 (-89.14%)
Mutual labels:  activerecord, mongoid, rails, gem
Counter culture
Turbo-charged counter caches for your Rails app.
Stars: ✭ 1,397 (+51.68%)
Mutual labels:  activerecord, rails, gem
React Tabulator
React Tabulator is based on tabulator - a JS table library with many advanced features.
Stars: ✭ 295 (-67.97%)
Mutual labels:  grid, table, tableview
Gridmanager
🌐 表格组件GridManager: 快速、灵活的对Table标签进行实例化,让Table标签充满活力。
Stars: ✭ 622 (-32.46%)
Mutual labels:  grid, table
Github Ds
A collection of Ruby libraries for working with SQL on top of ActiveRecord's connection
Stars: ✭ 597 (-35.18%)
Mutual labels:  activerecord, rails
Mobility
Pluggable Ruby translation framework
Stars: ✭ 644 (-30.08%)
Mutual labels:  activerecord, rails
Sheetjs
📗 SheetJS Community Edition -- Spreadsheet Data Toolkit
Stars: ✭ 28,479 (+2992.18%)
Mutual labels:  grid, table
Zero downtime migrations
Zero downtime migrations with ActiveRecord 3+ and PostgreSQL
Stars: ✭ 513 (-44.3%)
Mutual labels:  activerecord, rails
Rein
Database constraints made easy for ActiveRecord.
Stars: ✭ 657 (-28.66%)
Mutual labels:  activerecord, rails
Paper trail
Track changes to your rails models
Stars: ✭ 6,185 (+571.55%)
Mutual labels:  activerecord, rails
Datatable
A simple, modern and interactive datatable library for the web
Stars: ✭ 587 (-36.26%)
Mutual labels:  grid, table
Stateful enum
A very simple state machine plugin built on top of ActiveRecord::Enum
Stars: ✭ 546 (-40.72%)
Mutual labels:  activerecord, rails
Unread
Handle unread records and mark them as read with Ruby on Rails
Stars: ✭ 638 (-30.73%)
Mutual labels:  activerecord, rails
Activerecord Multi Tenant
Rails/ActiveRecord support for distributed multi-tenant databases like Postgres+Citus
Stars: ✭ 526 (-42.89%)
Mutual labels:  activerecord, rails
Yt
The reliable YouTube API Ruby client
Stars: ✭ 674 (-26.82%)
Mutual labels:  rails, gem
Materialize Sass
Materializecss rubygem for Rails Asset Pipeline / Sprockets
Stars: ✭ 785 (-14.77%)
Mutual labels:  rails, gem
Vue Handsontable Official
Vue Data Grid with Spreadsheet Look & Feel. Official Vue wrapper for Handsontable.
Stars: ✭ 751 (-18.46%)
Mutual labels:  grid, table
Jquery Rslitegrid
Input tabular data with your keyboard
Stars: ✭ 5 (-99.46%)
Mutual labels:  grid, table
Activerecordextended
Adds additional postgres functionality to an ActiveRecord / Rails application
Stars: ✭ 830 (-9.88%)
Mutual labels:  activerecord, rails

Datagrid

Build Status

FOSSA Status

Ruby library that helps you to build and represent table-like data with:

  • Customizable filtering
  • Columns
  • Sort order
  • Localization
  • Export to CSV

ORM Support

  • ActiveRecord
  • Mongoid
  • MongoMapper
  • Sequel
  • Array (slow but possible)

Create an issue if you want more.

Dependencies

  • Ruby >= 2.0
  • Rails >= 3.2

Live Demo

Datagrid DEMO application is available live! Demo source code.

Example

In order to create a grid:

class UsersGrid

  include Datagrid

  scope do
    User.includes(:group)
  end

  filter(:category, :enum, select: ["first", "second"])
  filter(:disabled, :xboolean)
  filter(:group_id, :integer, multiple: true)
  filter(:logins_count, :integer, range: true)
  filter(:group_name, :string, header: "Group") do |value|
    self.joins(:group).where(:groups => {:name => value})
  end

  column(:name)
  column(:group, order: -> { joins(:group).order(groups: :name) }) do |user|
    user.name
  end
  column(:active, header: "Activated") do |user|
    !user.disabled
  end

end

Basic grid api:

report = UsersGrid.new(
  :group_id => [1,2], 
  :logins_count => [1, nil],
  :category => "first",
  :order => :group,
  :descending => true
)

report.assets # => Array of User instances:
              # SELECT * FROM users WHERE users.group_id in (1,2) AND users.logins_count >= 1 AND users.category = 'first' ORDER BY groups.name DESC

report.header # => ["Name", "Group", "Activated"]
report.rows   # => [
              #      ["Steve", "Spammers", false],
              #      [ "John", "Spoilers", false],
              #      ["Berry", "Good people", true]
              #    ]
report.data   # => [ header, *rows]

report.to_csv # => Yes, it is

Grid DSL

In order to create a report, you need to define:

  • scope of objects to look through
  • filters that will be used to filter data
  • columns that should be displayed and sortable (if possible)

Scope

Default scope of objects to filter and display. In common case it is ActiveRecord::Base (or any other supported ORM) subclass with some generic scopes like:

scope do
  User.includes(:group)
end

More about scope

Filters

Each filter definition consists of:

  • name of the filter
  • type that will be used for value typecast
  • conditions block that applies to defined scope
  • additional options

Datagrid supports different type of filters including:

  • text
  • integer
  • float
  • date
  • datetime
  • boolean
  • xboolean - the select of "yes", "no" and any
  • enum - selection of the given values
  • string
  • dynamic - build dynamic SQL condition

More about filters

Columns

Each column is represented by name and code block to calculate the value.

column(:activated, :header => "Active", :order => "activated", :after => :name) do
  self.activated?
end

Some formatting options are also available. Each column is sortable.

More about columns

Front end

Using Generator

Datagrid has a builtin generator:

rails g datagrid:scaffold skills

That gives you some code to play with out of the box:

create  app/grids/skills_grid.rb
create  app/controllers/skills_controller.rb
create  app/views/skills/index.html.erb
route  resources :skills
insert  app/assets/stylesheet/application.css

Customize Built-in partials

In order to get a control on datagrid built-in partials run:

rake datagrid:copy_partials

Advanced frontend

All advanced frontend things are described in:

Frontend section on wiki

Questions & Issues

If you have a question of any kind, just make an issue and describe your problem in details.

Self-Promotion

Like datagrid?

Follow the repository on GitHub.

Read author blog.

License

FOSSA Status

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].