There are a few filter webpart in SharePoint available but they don’t give you the possibility to filter your data with wildcards.
You can use this workaround to do this:
On your viewpage (for example Allitems.aspx) you add a CEWP (content editor webpart) where we will add some html and javascript code.
Open the source editor and add these lines of code:
<P> </P>
<P>Enter your search query: <INPUT id=textboxSearchQuery size=75> <INPUT onclick=RedirectSearchQuery(); value=Search type=button> </P>
<P><EM>Use * as wildcard</EM></P>
<SCRIPT language=javascript type=text/javascript src=”/JQuery/jquery-1.5.min.js”></SCRIPT><SCRIPT language=javascript type=text/javascript>
//redirect seach query
function RedirectSearchQuery(){
var url=$(location).attr(‘href’).split(“?”)[0] + “?”;
var sQuery=$(“#textboxSearchQuery”).val();
if(sQuery!=””){
url=url + “FilterName=Title&FilterMultiValue=” + sQuery
$(location).attr(‘href’,url);
}
}
</SCRIPT>
In my example I use jQuery so you must have this library somewhere on you site. The hack is this:
“&FilterName=Title&FilterMultiValue=” + sQuery
The FilterName parameter is the name of the column you want to filter. The FilterMultiValue parameter is your search/filter query. You can use * as wildcard.
I based my solution on the article on Praveen Kumar’s blog.
Hi there. I’ve been looking for a way to utilize a textbox with the filter for a while now and it looks like you’ve nailed it. However, when I implement it I get a coupl of errors. I get an “invalid character” message on this line
var url=$(location).attr(‘href’).split(“?”)[0] + "?";
which I think leads to and “object expected” error on this lineEnter your search query:
. Any thoughts would be greatly appreciated .You sholud copy the script from below and exchange the ‘ and ” to the typical ‘ and ” from your keyboard. The copy procedure mistranslate the ‘ (e.g.) to a ´ or ` and this codes did not work. After this I get no errors andtry just now how to change the FilterName column.
Seems not easy or not to work, if it from a lookup field….
Hi,
I search for a way to implement this function in SharePoint 2013. I always get an “RedirectSearchQuery” not defined” error when clicking on the “search” button.
Any ideas? Thanks al lot.
regards
Dominik
Dominik
I did not have the time to test this on a SP2013 environment. The blog post was written in the SP2010 era 😉
You could also put the JavaScript code in a separate file in link it. Maybe the code editor mixed up you script. The error you get sounds like the function is not there.
Hi, I found another solution by using SharePoint Designer and list parameters/ filters. thank you.
It works fine in SP2013. I put the code in “Script Editor” web part instead of Content Editor.
Also, I removed the “wildcard” note and added *’s around the sQuery. Thanks for the great post.