On Thursday, March 3, 2011 11:44:41 AM UTC-5, Ross Peoples wrote: 
>
> That was a very helpful example. Thank you. So using the web2py TABLE 
> helpers is best used for creating simple, static tables where the rows 
> aren't generated?

 
I think you should be able to build a table programmatically using helpers. 
See the "TABLE, TR, TD" section here: 
http://www.web2py.com/book/default/chapter/05#Built-in-Helpers (shows an 
example using a list comprehension).
 

> I guess that's ok, I always thought that the controller was meant to get 
> the data, while the views format the data.

 
That's probably the right way to think about it (from an MVC perspective), 
though I suppose what it means for the view to get "the data" can be a 
judgment call. You have to decide how you want to structure the data before 
passing it to the view for presentation. In your case, it looks like you've 
got a single set of rows, which you are then breaking into multiple tables 
-- so you have to ask yourself whether it makes sense for the controller 
(business logic) to decide how to break up the rows into separate tables, or 
whether that's purely a presentation issue. If the former, then maybe create 
a data structure that breaks up the rows in the controller, and have the 
view simply build the table for each set of rows returned by the controller. 
You might also think about what you would want the controller to return in 
case its output was going to a different view (e.g., JSON) -- if you need to 
structure the data differently depending on the view, then it might make 
sense to do the structuring in the view rather than the controller.
 
Anthony

Reply via email to