El Grillo
 

What is
El Grillo?

El Grillo is a Ruby on Rails plugin that helps you show tabular data in a simple way. Main features are:

El Grillo focus in standard html so any html browser will be able to display the data. No fancy AJAX.

 

El Grillo is a work in progress, at a early development stage, so use it carefully. We strongly suggest you to download the source and help El Grillo grow.

El Grillo uses Ruby FPDF (for PDF export) and Rolando Abarca Millán's scio_excel.rb (for Excel 2006 export). Be sure to install them for the full El Grillo experience!

 

Installation

El grillo can be used as a RoR plugin. This means you can download it in your vendor/plugins directory. Additionally, you can copy the default style and images to your main project:

You can get the full sources from the project repository at RubyForge.

 

Example

The Controller:

      	
   def example
      	@grid = Grillo.new(
      		:order=>order_options,
      		:search=>search_options,
      		:pages=>pages_options,
      		:export=>export_options,
      		:title=>"Calls from the outside"
      	)
      	@grid.add_column("calldate",	:header=>'Date', :orderable=>true, :type=>:short_date)
      	@grid.add_column("clid",     	:header=>'Source', :type=>:phone, :searchable=>true, :orderable=>true)
     	@grid.add_column("dst",     	:header=>'Destiny', :type=>:phone, :orderable=>true)
     	@grid.add_column("duration",  	:header=>'Duration', :orderable=>true, :format=>'%s [min]', :type=>:number, :sql_select=>" duration/60 ")
     	@grid.add_column("dstchannel",	:header=>'Channel')
       	@grid.add_column("disposition",:header=>'State', :orderable=>true)
       	@grid.add_column("lastapp",	:header=>'Command')
     	@grid.fill_from_database(Cdr,	:conditions=>"src!='' and duration>'25'")
   end
     	

The View:

   	<%= render_grillo @grid %>
	

Produces the following output:

Just download the sample proyect and try it!

 

Docs

The main component of El Grillo is the column, that's because a data grid is composed by columns. There's four main groups of options for the columns:

OptionTypeDescription
Format Options
:width Numeric Width of the column.
:position Numeric Position of the column.
:header String Title for the column.
:align :center, :left, :rightSpeaks for itself.
Data Format
:type :stringFormat the data as String (aligned to the left).
:type :numberFormat the data as Numeric (aligned to the right).
:type :percentNumber ended with a '%' symbol.
:type :currencyNumber started with a '$' symbol.
:type :phoneNumber formatted as a phone.
:type :link_toCreates a link on the cell.
:type :link_image_toCreates an image link on the cell.
:type :hiddenCreates a hidden column (for :type => :value).
:type :hideCapture de data, but do not display it. Usefull for reference it from another column
:options HashOptions for some cell types (like :link_to and :image_link_to).
:format StringOverrides the default format, i.e "%s [min]".
Data Options
:code StringExecutes a code. Accepts Ruby primitives.
:sql_selectStringOverwrite the column portion of the 'SELECT' so you can execute database commands directly.
:value StringExecute operation between columns, referenced by its ids.
Column Options
:searchableBooleanEnables search on this column.
:orderable BooleanEnables order on this column.

The other part of a data grid is the data source. The method 'fill_from_database' accepts two parameters, the Object (a model) and a hash of parameters, same as the 'find' method.

Check this examples that shows El Grillo capabilities.
 

Credits and
License

El Grillo is developed by Marcelo Soto Montes and Phillip Neumann. Sponsored and supported by TransTel Ltda Chile, Servicios y Soluciones de Negocios Móviles.

The program is licensed under the MIT License. Use at your own risk