0

I'm trying to build a projects dashboard page of sorts, with HTML Form Filter Web Parts that will allow the user to select from filters, and have those filters connected to various document and list web parts on the page (risks, issues, open items, etc.).

I've got the following code which populates all of the project names to a dropdown list. This filter is working fine, but at present I only have a 'Clear All Filters' button (elsewhere on the page). Is there a way to add an 'All Projects' item to my dropdown list that would effectively clear this filter when applied? I plan on adding other filters (project owner, status, etc.), so the 'Clear All Filters' button doesn't seem like an optimal solution if the user wants to preserve the other filters that have been set.

Thanks in advance!

 function getListItemsForDropDown(){
        $().SPServices({
            operation:"GetListItems",
            webURL: $(this).attr("WebFullUrl"),
            async:false,
            listName: "Project List",
            CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
            CAMLQuery: "<Query><OrderBy><FieldRef Name='Title' Ascending='True' /></OrderBy></Query>",
            completefunc: function(xData, Status) {
                $(xData.responseXML).SPFilterNode("z:row").each(function() {
                    projName = $(this).attr("ows_Title");
                    listItem = "<option>" + projName + "</option>"
                    $("select.list-selector").append(listItem);
                })
            }
        })
    } // end function

1 Answer 1

0

Add an empty item to the select? i.e.:

var emptyListItem = "<option value=\"\">Select all</option>"
$("select.list-selector").prepend(emptyListItem);
3
  • Thanks Colin... I managed to get this far (though slightly differently), but it doesn't seem to actually clear the filter, or filter for all items, once one has been applied. From my reading thus far this seems to be a limitation of SharePoint, but I'm still looking for a solution.
    – PSUlion01
    Commented Mar 11, 2016 at 17:10
  • Run a different function onclick when "Select All" option is selected that reloads the page. And acts like a clear all filter. Commented Mar 11, 2016 at 17:52
  • Already have a 'Clear All Filters' button that does the page reload. I suppose I can do the same using the onClick, but I'd really like to preserve the other filters that have been set if possible.
    – PSUlion01
    Commented Mar 11, 2016 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.