Sunday 7 July 2013

sharepoint list Search using jquery

Search using jquery:

Reference url:http://geekswithblogs.net/SoYouKnow/archive/2011/01/26/sharepoint-list-views-ndashquick-amp-easy-jquery-filter.aspx

<script src="/sites/testingsite/SiteAssets/jquery-1.9.0.min.js" type="text/javascript"></script><script type="text/javascript">

jQuery(document).ready(function($){
    $('#filterInput').keyup(function()
    {
        DynamicFilter($('#filterInput').val());
    });
})
function stripHTML (field) {
    return field.replace(/<([^>]+)>/g,'');
}
function DynamicFilter(text)
{
    $('table [class="ms-listviewtable"]').find('tr').each(function()
        {
           
            if ($(this).attr("class") != "ms-viewheadertr ms-vhltr")
            {
                 source = stripHTML($(this).html());
                 text = text.toLowerCase();
                            source = source.toLowerCase();
                if (source.indexOf(text) < 0)
                {
                    $(this).hide();
                } else {
                   
                    $(this).show();
                }
            }
        }
    );
}</script><div id="mainDiv"><table><tbody><tr><td width="125" class="Filter">Search:&#160; <input id="filterInput" type="text"/></td></tr></tbody></table></div>
&#160;

No comments:

Post a Comment