Re: [Lift] Highlighting even/odd rows in a table

2009-12-16 Thread Ross Mellgren
Oh, speaking of jquery, tablesorter also has a "zebra" plugin that does this, 
so if you're tablesorter you can use that also.

-Ross

On Dec 16, 2009, at 9:01 PM, Alex Boisvert wrote:

> Or delegate the work to the browser using jQuery + CSS
> http://docs.jquery.com/Selectors/odd
> 
> alex
> 
> 
> On Wed, Dec 16, 2009 at 4:04 PM, Ross Mellgren  wrote:
> You could use customers.zipWithIndex.flatMap({ case (customer, index)
> => ... instead of customers.flatMap(customer => to get the index, and
> then use index % 2 == 0 to see if it's an even row or an odd row. How
> you get that style into your template is up to you -- using an
> attribute bind param would probably be pretty easy, or emitting the
>  straight out of the snippet.
> 
> If you need more guidance give a shout and I'll write you up some
> example code.
> 
> Note that zipWithIndex only works on List, and it regenerates the
> list, so if you have a bunch of customers on the page and are
> concerned about performance you might want to do something different
> (and less convenient).
> 
> -Ross
> 
> On Dec 16, 2009, at 5:59 PM, Stevo wrote:
> 
> > Say for a second that in one of my Snippets I have the following
> > binding:
> >
> >   def view(xhtml: NodeSeq): NodeSeq =
> >   {
> >   val entries: NodeSeq = Customer.findAll() match
> >   {
> >   case Nil => Text("No customers currently defined")
> >   case customers =>
> >   customers.flatMap(customer => bind("cust", 
> > chooseTemplate
> > ("customer", "entry", xhtml),
> >   "name" -> 
> > Text(emptyIfNull(customer.name.is)),
> >   "address" -> Text
> > (customer.workAddress.obj.open_!.singleTextLine),
> >   "phone" -> 
> > Text(emptyIfNull(customer.workPhone.is)),
> >   "other" -> 
> > Text(emptyIfNull(customer.other.is)),
> >   "fax" -> 
> > Text(emptyIfNull(customer.workFax.is)),
> >   "email" -> 
> > Text(emptyIfNull(customer.email.is)),
> >   "url" -> 
> > Text(emptyIfNull(customer.email.is
> >   }
> >   bind("customer", xhtml, "entry" -> entries)
> >   }
> >
> > Is there a way that I could apply a style to a complete customer:entry
> > with the goal of highlighting even/odd rows?
> >
> > Let me know and best regards to all,
> >
> >
> > Steve
> >
> > --
> >
> > --
> >
> > You received this message because you are subscribed to the Google
> > Groups "Lift" group.
> > To post to this group, send email to lift...@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
> > .
> >
> >
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Lift" group.
> To post to this group, send email to lift...@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.
> 
> 
> 
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Lift" group.
> To post to this group, send email to lift...@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.

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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.




Re: [Lift] Highlighting even/odd rows in a table

2009-12-16 Thread Alex Boisvert
Or delegate the work to the browser using jQuery + CSS
http://docs.jquery.com/Selectors/odd

alex


On Wed, Dec 16, 2009 at 4:04 PM, Ross Mellgren  wrote:

> You could use customers.zipWithIndex.flatMap({ case (customer, index)
> => ... instead of customers.flatMap(customer => to get the index, and
> then use index % 2 == 0 to see if it's an even row or an odd row. How
> you get that style into your template is up to you -- using an
> attribute bind param would probably be pretty easy, or emitting the
>  straight out of the snippet.
>
> If you need more guidance give a shout and I'll write you up some
> example code.
>
> Note that zipWithIndex only works on List, and it regenerates the
> list, so if you have a bunch of customers on the page and are
> concerned about performance you might want to do something different
> (and less convenient).
>
> -Ross
>
> On Dec 16, 2009, at 5:59 PM, Stevo wrote:
>
> > Say for a second that in one of my Snippets I have the following
> > binding:
> >
> >   def view(xhtml: NodeSeq): NodeSeq =
> >   {
> >   val entries: NodeSeq = Customer.findAll() match
> >   {
> >   case Nil => Text("No customers currently defined")
> >   case customers =>
> >   customers.flatMap(customer => bind("cust",
> chooseTemplate
> > ("customer", "entry", xhtml),
> >   "name" -> Text(emptyIfNull(
> customer.name.is)),
> >   "address" -> Text
> > (customer.workAddress.obj.open_!.singleTextLine),
> >   "phone" -> Text(emptyIfNull(
> customer.workPhone.is)),
> >   "other" -> Text(emptyIfNull(
> customer.other.is)),
> >   "fax" -> Text(emptyIfNull(
> customer.workFax.is)),
> >   "email" -> Text(emptyIfNull(
> customer.email.is)),
> >   "url" -> Text(emptyIfNull(
> customer.email.is
> >   }
> >   bind("customer", xhtml, "entry" -> entries)
> >   }
> >
> > Is there a way that I could apply a style to a complete customer:entry
> > with the goal of highlighting even/odd rows?
> >
> > Let me know and best regards to all,
> >
> >
> > Steve
> >
> > --
> >
> > --
> >
> > You received this message because you are subscribed to the Google
> > Groups "Lift" group.
> > To post to this group, send email to lift...@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
> > .
> >
> >
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to lift...@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.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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.




Re: [Lift] Highlighting even/odd rows in a table

2009-12-16 Thread Ross Mellgren
You could use customers.zipWithIndex.flatMap({ case (customer, index)  
=> ... instead of customers.flatMap(customer => to get the index, and  
then use index % 2 == 0 to see if it's an even row or an odd row. How  
you get that style into your template is up to you -- using an  
attribute bind param would probably be pretty easy, or emitting the  
 straight out of the snippet.

If you need more guidance give a shout and I'll write you up some  
example code.

Note that zipWithIndex only works on List, and it regenerates the  
list, so if you have a bunch of customers on the page and are  
concerned about performance you might want to do something different  
(and less convenient).

-Ross

On Dec 16, 2009, at 5:59 PM, Stevo wrote:

> Say for a second that in one of my Snippets I have the following
> binding:
>
>   def view(xhtml: NodeSeq): NodeSeq =
>   {
>   val entries: NodeSeq = Customer.findAll() match
>   {
>   case Nil => Text("No customers currently defined")
>   case customers =>
>   customers.flatMap(customer => bind("cust", 
> chooseTemplate
> ("customer", "entry", xhtml),
>   "name" -> 
> Text(emptyIfNull(customer.name.is)),
>   "address" -> Text
> (customer.workAddress.obj.open_!.singleTextLine),
>   "phone" -> 
> Text(emptyIfNull(customer.workPhone.is)),
>   "other" -> 
> Text(emptyIfNull(customer.other.is)),
>   "fax" -> 
> Text(emptyIfNull(customer.workFax.is)),
>   "email" -> 
> Text(emptyIfNull(customer.email.is)),
>   "url" -> 
> Text(emptyIfNull(customer.email.is
>   }
>   bind("customer", xhtml, "entry" -> entries)
>   }
>
> Is there a way that I could apply a style to a complete customer:entry
> with the goal of highlighting even/odd rows?
>
> Let me know and best regards to all,
>
>
> Steve
>
> --
>
> --
>
> You received this message because you are subscribed to the Google  
> Groups "Lift" group.
> To post to this group, send email to lift...@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 
> .
>
>

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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.




[Lift] Highlighting even/odd rows in a table

2009-12-16 Thread Stevo
Say for a second that in one of my Snippets I have the following
binding:

def view(xhtml: NodeSeq): NodeSeq =
{
val entries: NodeSeq = Customer.findAll() match
{
case Nil => Text("No customers currently defined")
case customers =>
customers.flatMap(customer => bind("cust", 
chooseTemplate
("customer", "entry", xhtml),
"name" -> 
Text(emptyIfNull(customer.name.is)),
"address" -> Text
(customer.workAddress.obj.open_!.singleTextLine),
"phone" -> 
Text(emptyIfNull(customer.workPhone.is)),
"other" -> 
Text(emptyIfNull(customer.other.is)),
"fax" -> 
Text(emptyIfNull(customer.workFax.is)),
"email" -> 
Text(emptyIfNull(customer.email.is)),
"url" -> 
Text(emptyIfNull(customer.email.is
}
bind("customer", xhtml, "entry" -> entries)
}

Is there a way that I could apply a style to a complete customer:entry
with the goal of highlighting even/odd rows?

Let me know and best regards to all,


Steve

--

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@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.