You could do something like this. Snippet:
def func(xhtml: NodeSeq): NodeSeq = { val foos = Foo.findAll(...) val rowSize = (S.attr("rowSize") openOr "10").toInt val rowNum = (foos.size + rowSize - 1) / rowSize List.range(0, rowNum).foldLeft(Util.emptyNodeSeq)((ns, i) => { val start = i*rowSize val end = start+rowSize ns ++ bind("list", xhtml, "row" -> row(foos.slice(start, end)) _) }) } private def row(foos:List[String])(xhtml: NodeSeq) : NodeSeq = foos.foldLeft(Util.emptyNodeSeq)((ns, foo) => ns ++ bind("foo", xhtml, "name" -> foo.name)) Then your template can use table/tr/td or it could just use floating divs that wrap over when necessary: <table> <lift:MyPage.func rowSize="10"> <tr> <list:row> <td><foo:name/></td> </list:row> </tr> </lift:MyPage.func> </table> OR <lift:MyPage.func> <list:row> <div class="cell"><foo:name/></div> </list:row> </lift:MyPage.func> For an empty NodeSeq that works in the foldLeft I've had to create the following. Anybody know a better way? object Util { val emptyNodeSeq : NodeSeq = NodeSeq.fromSeq(Seq(<xml:group></ xml:group>)) } On Aug 18, 2:58 pm, harryh <har...@gmail.com> wrote: > I have a List[Foo] and I want to construct a table with 10 columns and > however many rows necessary to contain all the Foos. I feel like I > should do something like so, but it's not quite right yet: > > <table> > <lift:MyPage.func> > <td><foo:name/></td> > </lift:MyPage.func> > </table> > > def func(xhtml: NodeSeq): NodeSeq = { > val cells: List[NodeSeq] = Foo.findAll(...).flatMap(foo => { > bind("foo", xhtml, "name" -> foo.name) > }) > > // then reduce the list of cells putting in <tr>s in appropriate > places, but not sure how. > > } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---