Creating a "Google Style" filter of a SharePoint List
Here is a simple jquery search which automatically filters whatever content is on the page as you type. You might need to create a view which shows all items since it can't search page 2 or anything grouped and collapsed.
You'll need the jquery .js file, but that's it. This is a very powerful script which I put in a content editor web part, exported the webpart .dwp file, then imported it into each site collection(s) making it available to all sites.
<script type="text/javascript" src="/Style Library/js/jquery-1.11.3.min.js"></script>
<input type="text" id="filter" onkeyup="keyupfunc(document.getElementById('filter').value);"></input> Search Contacts
<script type="text/javascript">
function keyupfunc()
{
var list = $("table.ms-listviewtable");
var listItems = $("table.ms-listviewtable tr:not(.ms-viewheadertr)");
var input = $("input#filter");
listItems.each(function()
{
var text = $(this).text().toLowerCase();
if (text.indexOf(input.val()) != -1)
{
$(this).show();
}
else
{
$(this).hide();
}
});
}
</script>
You'll need the jquery .js file, but that's it. This is a very powerful script which I put in a content editor web part, exported the webpart .dwp file, then imported it into each site collection(s) making it available to all sites.
<script type="text/javascript" src="/Style Library/js/jquery-1.11.3.min.js"></script>
<input type="text" id="filter" onkeyup="keyupfunc(document.getElementById('filter').value);"></input> Search Contacts
<script type="text/javascript">
function keyupfunc()
{
var list = $("table.ms-listviewtable");
var listItems = $("table.ms-listviewtable tr:not(.ms-viewheadertr)");
var input = $("input#filter");
listItems.each(function()
{
var text = $(this).text().toLowerCase();
if (text.indexOf(input.val()) != -1)
{
$(this).show();
}
else
{
$(this).hide();
}
});
}
</script>
I confirmed that this code still works on SharePoint 2013.
ReplyDelete