Rails/YUI-Grid Question

Hello. I’m looking at using the YUI grid component in a rails app.

Typically I’d use an html table object, do a db call along the lines of

@aCollection = AModel.find(:all)

& use a partial to loop thru the collection & populate the rows…

How would you populate the YUI grid in rails?

Would RJS &/or the rails “to_xml” method be part of a reasonable
approach here & if so, what would that look like?

Thanks!

Oh and here is a starting point:

http://wiki.rubyonrails.org/rails/pages/HowToWorkWithTheYUI

But I don’t see how he handles using XHR with YUI.

It’s going to depend more on how YUI works than rails. Honestly, I
haven’t had much expierence with YUI, but typically, YUI controls like
for you to render the entire HTML just like you normally do. After that
apply the javascript to your page to turn it into a grid. YUI
philosophy is more of the unobtrusive javascript which the rails guys
typically don’t do.

Now I’m not sure what it does for fetching data asynchronously. I don’t
think RJS would be that helpful since it’s built on top of the Prototype
library to create all the javascript. If you use RJS you’ll be
combining Prototype and YUI together. While it could work you’ll
probably run into strange issues combining them. You’ll have to be
careful if you take that approach. Personally I like to avoid weird
issues that no one will be able to help me with so I’d try to stear
clear of mixing protoype and YUI. That also means things like
remote_link_to might be off limits as well because that all generates
Prototype code as well.

Charlie

Charlie H. wrote:

It’s going to depend more on how YUI works than rails. Honestly, I
haven’t had much expierence with YUI, but typically, YUI controls like
for you to render the entire HTML just like you normally do. After that
apply the javascript to your page to turn it into a grid. YUI
philosophy is more of the unobtrusive javascript which the rails guys
typically don’t do.

Now I’m not sure what it does for fetching data asynchronously. I don’t
think RJS would be that helpful since it’s built on top of the Prototype
library to create all the javascript. If you use RJS you’ll be
combining Prototype and YUI together. While it could work you’ll
probably run into strange issues combining them. You’ll have to be
careful if you take that approach. Personally I like to avoid weird
issues that no one will be able to help me with so I’d try to stear
clear of mixing protoype and YUI. That also means things like
remote_link_to might be off limits as well because that all generates
Prototype code as well.

Charlie

Hey Charlie,

Thanks for your comments!

Seems I was confused… I was actually referring to the yui-ext grid
component by Jack Slocum http://www.jackslocum.com/yui/index.php.

The initial problem for me is that I don’t understand how to load the
grid once I have the query reults in a rails collection.

The grid api seems to provide several methods for loading data,
including xml & json. On learning that I thought of the rails to_xml &
to_json methods, but I’m still left with the question of how the data
gets passed into the grid…

As for adding rjs to the mix… your point is a good one!

I will continue to look into this & if/when I get a grip on it I’ll post
something on it.

Thanks again.

Randy