Microsoft

Blog Categories

Subscribe to RSS feed

Archives

Searching a SharePoint Document Library or List View Web Part Using SharePoint Designer

I was asked to add a search in a library using SharePoint Online that would bring the results in a “Grid View,” which essentially meant we want to filter our list items and we don’t want to use the default search at the top of the page (This Site: ___).

Originally I read a post about doing something similar, but it wouldn’t work for many commenters and myself included (I can’t remember the original article) however I do remember the error. The method worked, only returned results from the front page, and I don’t believe the wild card/partial search worked.

After some experimentation and brain storming I came to the realization that the problem had occurred because I converted the List View to a Dataview, which will not work. If you leave the list view on the page the method below will work fine. I then added this search on all of my different views within the library (this will work for a list as well).

Example:

 

Step 1: Create a view for your library (In Library Settings)

Step 2: Add A Form Web Part to The Page above the list

Step 3: Connect the Form web part with the List View (Using Connections near “Edit this Webpart”)

Step 4: Change the code in the Form Web Part to reflect your site, here is what it should look like:

<script type=”text/javascript”>

function filterItems() {

var partialID = document.getElementById(“myText”).value;

document.location.href = “[Relative path]?[Filtername]=[Column name of Column to filter on]&FilterMultiValue=*” + escape(partialID) + “*”;

;

}

</script>

<div onkeydown=”if (event.keyCode == 13) filterItems()” style=”color:#000099;”>

<br/>

&nbsp;&nbsp;<b>Search Project # </b>&nbsp;

<input type=”text” name=”T1″ id=”myText”/>

<input type=”button” value=”Go” onclick=”filterItems()”/>

<input type=”button” value=”Reset” onclick=”parent.location=’[URL Link to view]‘”/></div>

 

Let me know if you have any issues!

P.S. The reset button is required to clear the filter.

 

Thanks to Bert Johnson for helping me with the wildcard search.

Tags: ,

Leave a Reply