Active Grid on Rails - How to load data from db call?
Hello,
I'm wondering if there are any Rails users out there who have successfully integrated ActiveWidgets Grid & RoR.
======================================================
In a fairly typical use of Rails with RJS, I would load a table/grid something like the following:
-----------------------------------------------------
index.rhtml
----
code here to select category & trigger loading of the
table
----
<table>
<thead>
<tr>
<td> columnHead1 </td>
<td> columnHead2 </td>
<td> columnHead3 </td>
</tr>
</thead>
<tbody id="grid" class="scrollingContent">
</tbody>
</table>
---------------------------------------------------
main_controller.rb
.
.
.
def load_table
@things = Thing.find(:all)
---------------------------------------------------
_table_rows.rhtml
<% @things.each do |thing| -%>
<tr>
<td>
<%= thing.attribute1 %>
</td>
<td>
<%= thing.attribute2 %>
</td>
<td>
<%= thing.attribute3 %>
</td>
</tr>
<% end %>
---------------------------------------------------
load_table.rjs
page.insert_html :bottom, 'grid', :partial => 'table_rows', :object => @things
==================================================
So, typically, the controller creates the collection which, at the behest of the RJS template, is then used by the partial to load the table.
Assuming the collection is reformatted as xml (either manually or by using the Rails ".to_xml" method ), how would it then be loaded into the grid?
Would the ActiveWidgets ".setURL();" method be used?
What would the Rails code look like?
Thanks!
I'm wondering if there are any Rails users out there who have successfully integrated ActiveWidgets Grid & RoR.
======================================================
In a fairly typical use of Rails with RJS, I would load a table/grid something like the following:
-----------------------------------------------------
index.rhtml
----
code here to select category & trigger loading of the
table
----
<table>
<thead>
<tr>
<td> columnHead1 </td>
<td> columnHead2 </td>
<td> columnHead3 </td>
</tr>
</thead>
<tbody id="grid" class="scrollingContent">
</tbody>
</table>
---------------------------------------------------
main_controller.rb
.
.
.
def load_table
@things = Thing.find(:all)
---------------------------------------------------
_table_rows.rhtml
<% @things.each do |thing| -%>
<tr>
<td>
<%= thing.attribute1 %>
</td>
<td>
<%= thing.attribute2 %>
</td>
<td>
<%= thing.attribute3 %>
</td>
</tr>
<% end %>
---------------------------------------------------
load_table.rjs
page.insert_html :bottom, 'grid', :partial => 'table_rows', :object => @things
==================================================
So, typically, the controller creates the collection which, at the behest of the RJS template, is then used by the partial to load the table.
Assuming the collection is reformatted as xml (either manually or by using the Rails ".to_xml" method ), how would it then be loaded into the grid?
Would the ActiveWidgets ".setURL();" method be used?
What would the Rails code look like?
Thanks!
randy
November 3,