[Lift] Re: generating columns

Mon, 26 Oct 2009 14:36:02 -0700

Thanks, Naftoli -- so are you suggesting a separate template for the
TD and for the TR? bind the TD template, and then concatenate them up
for each row?

nevertheless, I started out with this:

  var columns : Set

  def buildHeader : NodeSeq = {
    <TR>{columns.map{<TD>{_}</TD>}.reduceLeft(_+_)) }</TR>
  }

but i couldn't figure out the right incantation, and went for the easy
way out

  def buildHeader : NodeSeq = {
    val result="<TR>" + (if (columns.isEmpty) "" else columns.map
{"<TD>" + _ + "</TD>"}.reduceLeft(_+_)) + "</TR>"
    XML.loadString(result)
  }




On Oct 26, 4:47 pm, Naftoli Gugenheim <naftoli...@gmail.com> wrote:
> Sorry I can't give you code, but the key here is the the BindParam can take a 
> function from a NodeSeq to a NodeSeq. Say each column represents a field.
>   "eachfield"  ->  bindIndividualFields
> where bindIndividalField is a function that takes and returns a NodeSeq. Its 
> input will be the contents of <prefix:eachfield>. Inside the function do a 
> flatMap on your list of fields, and pass it another call to bind, passing 
> bind the input to bindIndividualFields. Thus you are calling bind on the 
> contents of eachfield repetitiously for each field, and concatenating (via 
> flatMap) the outputs of bind.
>
> -------------------------------------
>
> bob<rbpas...@gmail.com> wrote:
>
> PS: I know I can generate the TABLE, THEAD, TBODY, TR and TD elements
> directly in my snippet (although SHtml doesnt seems to be geared
> towards FORMs, rather than HTML generation like htmlKona)
>
> On Oct 26, 4:30 pm, bob <rbpas...@gmail.com> wrote:
>
>
>
> > "Listing 2.7: The Embedded Expense Table" in the LiftBook.pdf, page
> > 19, has a great example of generating individual rows of a table.
>
> > But lets say you wanted to generate the columns in the table, as well
> > as the rows.
>
> > is there a good example of how to do this in a template+snippet?
>
> > TIA, bob
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to