SPServices as a ListFilter

Apr 15, 2013 at 2:24 PM
How can I use SPServices to provide a cascade list view filter?

List:
Vendor Name, Product, Sub Product
Vendor 1, Bread, Burger Buns
Vendor 2, Bread, Wraps
Vendor 3, Drinks, Soda
Vendor 4, Drinks, Soda
Vendor 5, Drinks, Tea

Goal:
On list view , or page with the list view web part have two drop downs:
Drop Down 1 [Product] -> Drop Down 2 [Sub Product]

When drop down 1 is selected it filters the list view and limits drop down 2 to sub items of drop down 1's type.
EG:

Select Drinks from drop down 1. Drop down 2 allows choice of Soda and Tea. List view shows Vendor 3, 4, and 5.
Select Tea from drop down 2. List shows vendor 5 only.
Coordinator
Apr 15, 2013 at 2:29 PM
Have you looked at SPCascadeDropdown? You'll need to rearrange your data a bit (to normalize it), but you should be good to go.

However, it sounds like you want to do this on a view, not a form? SPCascadeDropdowns isn't built to work outside of forms, but the logic isn't that difficult to replicate with known dropdowns.

M.
Apr 15, 2013 at 3:04 PM
I did look at the SPCascadeDropdown, and yes we are trying to use this for a view so that is why I wasn't sure if it was possible or not.
Coordinator
Apr 15, 2013 at 3:12 PM
Ok, so the answer is "no". I tend to use a DVWP for something like what you describe or jQuery. SPCascadeDropdowns can work reliably on the forms because the structures, while overly complex, are predictable.

On a view, it's a bit more complex. and views can be changed by the user. In other words, something that is in column 1 today might be in column 9 tomorrow. It's very hard to generalize. If you've got the two dropdowns in the page and have a data source for each, you should be able to rig something up releatively easily using GetListItems. Since the dropdowns are in a view, you don't have to worry about the complex dropdowns that SharePoint sticks in the forms.

M.