<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -14,16 +14,29 @@ module Yui4Rails
     end
 
     def yui_datatable(statistics, div_id, options = {})
-      return 'No data found.' if statistics.rows.empty?
-      model = statistics.rows.first.class 
-
-      data = statistics.rows.map(&amp;:to_hash)
-      footer = &quot;&lt;tr class =\&quot;totals_row\&quot;&gt;#{statistics.footer_row_fields.map { |field| &quot;&lt;td&gt;&lt;div class=\&quot;yui-dt-liner\&quot;&gt;#{field.to_s}&lt;/div&gt;&lt;/td&gt;&quot; }.join('')}&lt;/tr&gt;&quot;
-      Yui4Rails::Widgets::DataTable.new(:col_defs =&gt; model.table_def,
-                                        :data_rows =&gt; data,
-                                        :footer_row =&gt; footer,
-                                        :table_div_id =&gt; div_id,
-                                       :table_id =&gt; 'yui_table').render
+      rows = options[:data_array] || statistics.rows
+      return 'No data found.' if rows.empty?
+      model = rows.first.class 
+
+      data = rows.map(&amp;:to_hash)
+
+      table_def = model.table_def
+      table_options = {}
+
+      unless table_def.first.delete(:skip_footer)
+        footer = &quot;&lt;tr class =\&quot;totals_row\&quot;&gt;#{statistics.footer_row_fields.map { |field| &quot;&lt;td&gt;&lt;div class=\&quot;yui-dt-liner\&quot;&gt;#{field.to_s}&lt;/div&gt;&lt;/td&gt;&quot; }.join('')}&lt;/tr&gt;&quot;
+        table_options[:footer_row] = footer
+      end
+
+      table_options[:row_formatter] = table_def.first.delete(:row_formatter) if table_def.first[:row_formatter]
+      table_options[:head_script] = table_def.first.delete(:head_script) if table_def.first[:head_script]
+
+      table_options[:col_defs] = table_def
+      table_options[:data_rows] = data
+      table_options[:table_div_id] = div_id
+      table_options[:table_id] = 'yui_table'
+
+      Yui4Rails::Widgets::DataTable.new(table_options).render
     end
 
   </diff>
      <filename>lib/yui4rails/helpers_extension.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,31 +1,31 @@
 module Yui4Rails
-	module Widgets
-	
-	  class Formatter; end
+  module Widgets
+  
+    class Formatter; end
 
-	  class NumberFormatter &lt; Formatter
-	    def self.to_s
-				&quot;number&quot;
-	    end
-	  end
+    class NumberFormatter &lt; Formatter
+      def self.to_s
+        &quot;number&quot;
+      end
+    end
 
-	  class CurrencyFormatter &lt; Formatter
-	    def self.to_s
-	      &quot;currency&quot;
-	    end
-	  end
+    class CurrencyFormatter &lt; Formatter
+      def self.to_s
+        &quot;currency&quot;
+      end
+    end
 
-	  def self.extract_keys(data_rows)
-	    keys = []
-	    return keys if data_rows.empty?
+    def self.extract_keys(data_rows)
+      keys = []
+      return keys if data_rows.empty?
 
-	    data_rows.first.each do |k, v|
-	      keys &lt;&lt; { :key =&gt; k.to_s }
-	    end
-	    keys
-	  end
+      data_rows.first.each do |k, v|
+        keys &lt;&lt; { :key =&gt; k.to_s }
+      end
+      keys
+    end
 
-	  class DataTable
+    class DataTable
       # Initialize new DataTable object
       # accepts either a list of arguments for backward compatability
       # or a hash of options.
@@ -35,6 +35,8 @@ module Yui4Rails
       # * &lt;tt&gt;:col_defs&lt;/tt&gt;: Hash of column definitions
       # * &lt;tt&gt;:data_rows&lt;/tt&gt;: Hash of data rows
       # * &lt;tt&gt;:footer_row&lt;/tt&gt;: footer div id.  -See ActiveWarehouse for the yui_adapter than uses this
+      # * &lt;tt&gt;:row_formatter&lt;/tt&gt;: string containing a Javascript function for row formatting
+      # * &lt;tt&gt;:head_script&lt;/tt&gt;: string containing Javascript to push into the head of the page
       # * &lt;tt&gt;:options&lt;/tt&gt;: additional hash of options, including :table_id, the
       # DOM element ID for the HTML table
       #
@@ -74,6 +76,8 @@ module Yui4Rails
           if @data_rows and !@data_keys
             @data_keys = Widgets.extract_keys(@data_rows)
           end
+          @row_formatter = options.delete(:row_formatter)
+          head_script = options.delete(:head_script)
           @configs = options
         when String
           @table_div_id = args[0]
@@ -83,7 +87,8 @@ module Yui4Rails
           @footer_row = args[3] || ''
           @configs = args[4] || {}
         end
-				Yui4Rails::AssetManager.manager.add_components :datatable
+        Yui4Rails::AssetManager.manager.add_components :datatable
+        Yui4Rails::AssetManager.manager.add_script head_script if head_script
       end
 
       # Add pagination to YUI datatable.
@@ -111,18 +116,16 @@ module Yui4Rails
         self.send(meth)
       end
 
-	    def render_from_html
-	      &lt;&lt;-PAGE
+      def render_from_html
+        &lt;&lt;-PAGE
         &lt;script type=&quot;text/javascript&quot;&gt;
-        #{get_configs}
+          #{get_configs}
           YAHOO.util.Event.addListener(window, &quot;load&quot;, function() {
             YAHOO.example.EnhanceFromMarkup = new function() {
               var myColumnDefs = #{col_defs_to_json};
               this.parseNumberFromCurrency = function(sString) {
-                //remove commas
-                sString = sString.replace(/,/, '');
-                // Remove dollar sign and make it a float
-                return parseFloat(sString.substring(1));
+                sString = sString.replace(/,/, ''); //remove commas
+                return parseFloat(sString.substring(1)); // Remove dollar sign and make it a float
               };
               this.myDataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get(&quot;#{@table_id}&quot;));
               this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
@@ -131,32 +134,33 @@ module Yui4Rails
               };
               this.myDataTable = new YAHOO.widget.DataTable(&quot;#{@table_div_id}&quot;, myColumnDefs,
               this.myDataSource, myConfigs);
-
             };
           });
           &lt;/script&gt;
         PAGE
       end
 
-	    def render_from_json
-	      &lt;&lt;-PAGE
-	      &lt;div id=&quot;#{@table_div_id}&quot; class=&quot;yui-skin-sam&quot;&gt;&lt;/div&gt;
-	      &lt;script type=&quot;text/javascript&quot;&gt;
-	      YAHOO.util.Event.addListener(window, &quot;load&quot;, function() {
-	        var myData = #{@data_rows.to_json};
-	        var myColumnDefs = #{@col_defs.to_json};
-	        myDataSource = new YAHOO.util.DataSource(myData);
-	        myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
-	        myDataSource.responseSchema = {
-	          fields: #{@data_keys.to_json}
-	        };
-	        this.myDataTable = new YAHOO.widget.DataTable(&quot;#{@table_div_id}&quot;, myColumnDefs, myDataSource);
-					$(myDataTable.getTableEl()).createTFoot().innerHTML = '#{@footer_row}';
-
-	      });
-	      &lt;/script&gt;
-	      PAGE
-	    end
+      def render_from_json
+        &lt;&lt;-PAGE
+        &lt;div id=&quot;#{@table_div_id}&quot; class=&quot;yui-skin-sam&quot;&gt;&lt;/div&gt;
+        &lt;script type=&quot;text/javascript&quot;&gt;
+        #{@row_formatter.values.first if @row_formatter}
+        YAHOO.util.Event.addListener(window, &quot;load&quot;, function() {
+          var myData = #{@data_rows.to_json};
+          var myColumnDefs = #{@col_defs.to_json};
+          myDataSource = new YAHOO.util.DataSource(myData);
+          myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
+          myDataSource.responseSchema = {
+            fields: #{@data_keys.to_json}
+          };
+          this.myDataTable = new YAHOO.widget.DataTable(&quot;#{@table_div_id}&quot;,
+                                                        myColumnDefs,
+                                                        myDataSource#{&quot;, {formatRow: #{@row_formatter.keys.first}}&quot; if @row_formatter});
+          $(myDataTable.getTableEl()).createTFoot().innerHTML = '#{@footer_row}';
+        });
+        &lt;/script&gt;
+        PAGE
+      end
 
       private
       # Constructs the myConfigs JavaScript variable if pagination or intial sort is used
@@ -196,6 +200,6 @@ module Yui4Rails
           gsub(/FromCurrency\&quot;/, 'FromCurrency').
           gsub(/\&quot;this\./, 'this.')
       end
-	  end
-	end
+    end
+  end
 end</diff>
      <filename>lib/yui4rails/widgets/datatable.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a0198b2d558bc5a84d5cf981e1f88988c0c64fdc</id>
    </parent>
  </parents>
  <author>
    <name>Marty Haught</name>
    <email>mghaught@gmail.com</email>
  </author>
  <url>http://github.com/mghaught/yui4rails/commit/927a5ec7f2ce36a5238e252c4d6c5bcd12efd190</url>
  <id>927a5ec7f2ce36a5238e252c4d6c5bcd12efd190</id>
  <committed-date>2008-11-21T15:36:27-08:00</committed-date>
  <authored-date>2008-11-21T15:36:27-08:00</authored-date>
  <message>SMC enhancements to datatable</message>
  <tree>6363f75f9eecde2bfdd10f6352268b818d3d4159</tree>
  <committer>
    <name>Marty Haught</name>
    <email>mghaught@gmail.com</email>
  </committer>
</commit>
