bob <[email protected]> writes:
> "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
Here's some sample (based on, tada, CRUDify :-). There's some extra
stuff in there, but you should be able see the idea. If not, ask away...
/Jeppe
Template:
<lift:crud.all>
{_showAllHeader}
<table id={showAllId} class={"tablesorter "+showAllClass}>
<thead>
<tr>
<th> </th>
<crud:header_item><th crud:style=""><crud:name/></th></crud:header_item>
</tr>
</thead>
<tbody>
<crud:row>
<tr>
<td>{itemListActionsTemplate}</td>
<crud:row_item><td
nowrap="nowrap"><crud:value/></td></crud:row_item>
</tr>
</crud:row>
</tbody>
</table>
</lift:crud.all>
Snippet:
def doCrudAll(in: NodeSeq): NodeSeq = {
val list = findAll(findForListParams : _*)
def doHeaderItems(in: NodeSeq): NodeSeq = listFields(list.head).flatMap(f
=> bind("crud", in, "name" -> f.displayHtml,
AttrBindParam("style",Text(columnStyle(f.dbColumnName)), "style")))
def doRows(in: NodeSeq): NodeSeq =
list.flatMap{
c =>
def doRowItem(in: NodeSeq): NodeSeq = listFields(c).flatMap(f =>
bind("crud", in, "value" -> f.asHtml))
itemListActions(c,bind("crud", in , "row_item" -> doRowItem _))
}
if (list.isEmpty)
_showAllHeader ++ <div>Der er ingen data.</div>
else
bind("crud", in, "header_item" -> doHeaderItems _,
"row" -> doRows _)
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---