This project has moved and is read-only. For the latest updates, please go here.

GroupBy and Spservices/Jquery on a list

Feb 6, 2012 at 3:00 AM

Not really an SPServices question... as much Jquery maybe.

Let's say I have a list called EVENTS with columns called TITLE and CATEGORY.  I want to produce the following with the help of SPServices:

    <ul>Category One
      <li>Some Title 1</li>
      <li>Some Title 2</li>

    <ul>Category Two
      <li>Some Title 3</li>
      <li>Some Title 4</li>

    <ul> Cateogyr Three
      <li>Some Title 5</li>
      <li>Some Title 6</li>

Obviously I could do this more easily with a DVWP or CQWP, but I'm trying to stay client-side here.  I know I can throw in a GroupBy into the CAMLQuery, but how do I show the group headers?  Or maybe that's not even how I would do it.  Ideas?

Feb 6, 2012 at 2:08 PM

What you can do in jQuery is simply iterate through the items (making sure that they are sorted in the order that you need above) and emit the <ul> whenever the value of Category changes.


Feb 6, 2012 at 2:13 PM

Ha, maybe I'm not as dumb as I thought.  I was doing just that but thought there might be an easier way that I was completely overlooking.