The filter don't include the top item

Apr 29, 2016 at 8:03 AM
Edited Apr 29, 2016 at 8:06 AM
The top item don’t seem to be included in the script below cause it’s always there no matter what I put in the searchfield.

Anyone else have that problem?
<script src="https://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
<script src="https://www.google.com/jsapi" type="text/javascript"></script> 

<script type="text/javascript">

$(document).ready(function()
{   
    jQuery.extend(jQuery.expr[':'], {
        containsIgnoreCase: function(a,i,m) {return (a.textContent||a.innerText||jQuery(a).text()||'').toLowerCase().indexOf((m[3]||'').toLowerCase())>=0}
     });

    $("table.ms-listviewtable tr.ms-viewheadertr").each(function()
    {
        if($("td.ms-vh-group", this).size() > 0)
        {
            return; 
        }
        
        var tdset = "";
        
        var colIndex = 0;
        
        $(this).children("th,td").each(function()
        {
            if($(this).hasClass("ms-vh-icon"))
            {
                // attachment
                tdset += "<td></td>";
            }
            else
            {
                // filterable
                tdset += "<td><input type='text' class='vossers-filterfield' filtercolindex='" + colIndex + "' /></td>";                
            }
            
            colIndex++;
        });
        
        var tr = "<tr class='vossers-filterrow'>" + tdset + "</tr>";
        
        $(tr).insertAfter(this);
    }); 
    
    
    $("input.vossers-filterfield")
        .css("border", "1px solid #7f9db9")
        .css("width", "100%")
        .css("margin", "2px")
        .css("padding", "2px")
        .keyup(function()
        {           
            var inputClosure = this;
            
            if(window.VossersFilterTimeoutHandle)
            {
                clearTimeout(window.VossersFilterTimeoutHandle);
            }
            
            window.VossersFilterTimeoutHandle = setTimeout(function()
            {
                var filterValues = new Array();
                
                $("input.vossers-filterfield", $(inputClosure).parents("tr:first")).each(function()
                {               
                    if($(this).val() != "")             
                    {
                        filterValues[$(this).attr("filtercolindex")] = $(this).val();
                    }
                });     
                
                            
                $(inputClosure).closest(".ms-listviewtable").find("tbody tr").nextAll("tr").each(function()
                {
                    var mismatch = false;
                    
                    $(this).children("td").each(function(colIndex)
                    {
                        if(mismatch) return;
                        
                        if(filterValues[colIndex])
                        {
                            var val = filterValues[colIndex];
                            
                            // replace double quote character with 2 instances of itself
                            val = val.replace(/"/g, String.fromCharCode(34) + String.fromCharCode(34));                         
                                                                                
                            if($(this).is(":not(:containsIgnoreCase('" + val + "'))"))
                            {
                                mismatch = true;
                            }                       
                        }
                    });
                    
                    if(mismatch)
                    {
                        $(this).hide();
                    }
                    else
                    {
                        $(this).show();
                    }       
                });             
                
            }, 250);
        });
}); 


</script> 
Aug 24, 2016 at 6:31 PM
I too am having the same problem along with it only filtering the first page of the data in the list. It would be nice to see a response to this and all other inquiries in other discussions about this topic. Please address rather than ignore. Thank you.
Jan 30 at 7:28 PM
Hello,

See the discussion thread here: https://instantlistfilter.codeplex.com/discussions/451733

I have posted my fix to the problem with the first item not being included in the filtering.

Cheers,
Lawrence L.