# Rico LiveGrid - how to incorporate it?

**URL:** <https://www.ruby-forum.com/t/rico-livegrid-how-to-incorporate-it/79774>\
**Category:** Rails\
**Created:** [December 18, 2006, 10:56pm UTC](https://www.ruby-forum.com/t/rico-livegrid-how-to-incorporate-it/79774 "2006-12-18T22:56:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![shauna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@shauna](https://www.ruby-forum.com/u/shauna)\
**Post date:** [December 18, 2006, 10:56pm UTC](https://www.ruby-forum.com/t/rico-livegrid-how-to-incorporate-it/79774/1 "2006-12-18T22:56:28Z")

</div>

I’m trying to incorporate Rico’s LiveGrid functionality into a Rails  
page.

So far I’ve been able to download rico.js into my public/javascripts  
folder and load it into the section of my application.rhtml using  
javascript\_include\_tag. Following Rico’s tutorial at  
[http://openrico.org/docs/RicoLiveGrid.pdf](http://openrico.org/docs/RicoLiveGrid.pdf), I added the option  
onload=“javascript:bodyOnLoad()” to my in application.rhtml.

Moving to the next step in the tutorial, I gave my existing Borrowers  
table an id=“data\_grid\_content” and created a header row table with  
id=“data\_grid\_header”.

Now to the problem step, the JavaScript function to actually create the  
grid. The tutorial uses JSP to load its table, and I want to use Rails -  
the instance variable @borrowers holds the proper page of data in the  
pre-Rico pagination setup. The code in the tutorial is:

I tried substituting @borrowers for getMovieTableContent.do (both with  
and without the single quote marks). The result in either case is no  
response - the existing page (with the added header row) shows up as  
before. No grid appears. There is no error or flash message.

Can anyone help with this? I know it’s just a matter of what/how to  
substitute and maybe also some layout issue with needing extra

 or

 sections. Since prototype.js is already part of Rails and rico.js uses Prototype, I thought it should be easy to incorporate Rico widgets into a Rails app. But I haven't found any Rails LiveGrid examples out there.

Shauna

---

<div class="post-metadata">

**Author:** ![shauna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@shauna](https://www.ruby-forum.com/u/shauna)\
**Post date:** [December 18, 2006, 11:20pm UTC](https://www.ruby-forum.com/t/rico-livegrid-how-to-incorporate-it/79774/2 "2006-12-18T23:20:43Z")

</div>

Just a stab here (I’m not positive), but it would seem to me that you  
would need to supply a Rails action name in place of  
‘getMovieTableContent.do’ that would output some sort of data  
structure. I don’t know what that would be, but I’m sure the  
tutorial/javascript file can tell you.

–Jeremy

---

<div class="post-metadata">

**Author:** ![shauna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@shauna](https://www.ruby-forum.com/u/shauna)\
**Post date:** [December 18, 2006, 11:22pm UTC](https://www.ruby-forum.com/t/rico-livegrid-how-to-incorporate-it/79774/3 "2006-12-18T23:22:44Z")

</div>

Sorry for not catching the PDF link before; it looks like you need to  
create a Rails action that outputs an HTML table. Rico then appears  
to take the HTML table and turn it into the grid. The tutorial shows  
how you need to format the output if you’re using AJAX.

–Jeremy

---

<div class="post-metadata">

**Author:** ![shauna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@shauna](https://www.ruby-forum.com/u/shauna)\
**Post date:** [December 18, 2006, 11:42pm UTC](https://www.ruby-forum.com/t/rico-livegrid-how-to-incorporate-it/79774/4 "2006-12-18T23:42:02Z")

</div>

Thanks for responding, Jeremy.

Yes, I have an existing borrowers/list.rhtml page that displays a page  
of Borrowers data, which I previously created based on the depot app in  
AWDwR. To generate that page, the borrowers\_controller.rb has a method  
def list  
@borrower\_pages, @borrowers = paginate :borrowers, :per\_page =\> 8,  
:order\_by =\> ‘LastName, FirstName’  
end

This appears to collect a page of data into the @borrowers variable. So  
do I need to refactor or rename this def somehow? How would I refer to a  
controller method in the example instead of in-line js code?

Shauna

---

<div class="post-metadata">

**Author:** ![shauna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@shauna](https://www.ruby-forum.com/u/shauna)\
**Post date:** [December 19, 2006, 4:40am UTC](https://www.ruby-forum.com/t/rico-livegrid-how-to-incorporate-it/79774/5 "2006-12-19T04:40:59Z")

</div>

If I’m reading it correctly, getMovieTableContent.do is merely  
pointing to a URL for a JSP. So, in theory you should be able to put  
‘list’ (or something like that) and get your desired output.

Of course, this is all in theory. I’m not sure if they have some  
special wiring with JSPs or not. I would suggest creating a  
plain-jane HTML file and plugging in a simple table in there to test  
that theory (i.e., create ‘table.html’ and replace  
getMovieTableContent.do with ‘table.html’).

I’m downloading Rico right now…if that doesn’t solve it I’ll play  
around with it and see if I can give you a solution. 🙂

–Jeremy

---

<div class="post-metadata">

**Author:** ![shauna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@shauna](https://www.ruby-forum.com/u/shauna)\
**Post date:** [December 19, 2006, 6:20am UTC](https://www.ruby-forum.com/t/rico-livegrid-how-to-incorporate-it/79774/6 "2006-12-19T06:20:18Z")

</div>

I tried replacing ‘getMovieTableContent.do’ with ‘table.html’ and  
replacing my Rails table-generating code with the expanded table that it  
turns into in the View / Page Source. It didn’t make any difference. I  
still get the normal rendering of the table. (I put this in a  
borrowers/listRico.rhtml template file and pointed the list action  
there. I know it got there because I changed the header row only in that  
template and that part rendered properly, just no liveGrid showed up.)

Now I suspect I might have to do something in the .css file, or maybe I  
left out some other crucial piece. The sample site has more and  
different code than the tutorial, but the sample site includes other  
widgets on the same page as well.

Thanks for checking out Rico! I came across a couple of other attempts  
to do this in the forum but no one actually said they got it.

–Shauna

---

<div class="post-metadata">

**Author:** ![shauna](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@shauna](https://www.ruby-forum.com/u/shauna)\
**Post date:** [December 19, 2006, 10:58am UTC](https://www.ruby-forum.com/t/rico-livegrid-how-to-incorporate-it/79774/7 "2006-12-19T10:58:04Z")

</div>

Hey, Jeremy -

I found an example of incorporating Rico LiveGrid into a rails app.  
Well, it’s not exactly _incorporating_ it; it’s a standalone example, so  
I have to figure out how to divide up the js parts to be more generic.  
That is, I don’t want to reference “Borrowers” in my application.rb,  
which is where the \<body onload= … element is.

Anyway, here’s the reference if you or anyone else want to play with it:

> **[Standalone Ajax example of Rico 1.1 LiveGrid](https://richardcowin.typepad.com/blog/2006/01/new_livegrid_ma.html)**
>
> As promised, here is a standalone example of the LiveGrid with the cleaner markup from Rico 1.1 final release. This is an extraction of the datagrid demo used on the openrico.org site. The example is in RoR, so you will need rails installed on your...

Shauna
