Ruby on Rails Data Grid Control 14
As far as I can tell, Ruby on Rails doesn’t have a built in control for displaying tabular data in a grid. Not a rich one anyway, with paging/sorting/filtering capability built-in. I plan on attempting to create one. I’m actually almost there. I’m doing this instead of getting my actual projects done. :)
All parameters should have defaults to do the standard thing, with ability to further customize if so desired. Convention over configuration and all that. It should be able to do sorting/paging on columns from associated tables as well. Here’s the proposed syntax for how this might be called in a controller:
a simple exampleclass AgreementsController < ApplicationController
def list_simple
grid_view(Agreement,
:columns => ['title', 'active', 'amount', 'frequency']
)
end
enda more complex example:
class AgreementsController < ApplicationController
def list_complex
grid_view(
Agreement,
:columns => [
"Status",
"Company Name" => {
:dbcolumn => "company_name",
:filter => true
},
"Category" => {
:dbcolumn => "agreement.category_id",
:filter => true,
:filter_type => :select,
:filter_options => Category.find_all.collect {|c| [ c.name, c.id ] }
},
"Active" => {
:dbcolumn => "agreement.active",
:filter => true,
:filter_type => :select,
:filter_options => [["Yes", 1], ["No", 0]]
}
],
:joins => ["LEFT OUTER JOIN categories ON agreements.category_id = categories.id",
"LEFT OUTER JOIN companies ON agreements.company_id = company.id"]
:alias_columns => [["companies.name", "company_name"],["categories.name", "category_name"]],
:order_by => "category_name, products.name",
:per_page => 25
)
end
endThe grid_view method will be at the application level, so you can call it from any controller. The presentation (view) will live in one /shared/_grid_view.rhtml partial file and be 100% customizable. And because of that, it doesn’t even have to be a table or look like a grid! The MVC pattern of rails allows this, and would make this far superior and easier to customize than say – the ASP.NET data grid control, in my opinion. Here’s one possible way such a beast might look like:

still no progress? :(
Is there any source code available? I would like to use a datagrid with it’s data stored in a mysql database for my project. I need a possibility to add rows and sort colums and I need a Cell editing capability. First I googled through ajax solutions because I wanted editable cells by mouseclick, but I couldn’t find a simple non commercial framework.
I would use your Datagrid MANY times if it was going. I’ve conerting my efforts from ASP and was using the DevExpress datagrid. How about letting me know how it’s going? dak AT itracker DOT com
Any progress in the project…
I’m interested in this project as well. Any chance you will pick it up almost two years later?
i would love if such a datagrid is availaible on rails
Any news on the Rails datagrid?
Any progress on this grid?
Creating tabular data in a grid form is no easy task…I read some other ruby rails blogs and they are struggling with it.
repost?
Check this out – https://redmine.wice.eu/wiki/wice-grid
man that was a long time ago. maybe this dude died or something…and where did he get that screenshot? photoshop?
man that was a long time ago. maybe this dude died or something…and where did he get that screen shot? photo shop?