Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用此代码过滤网格的所有列?_Javascript_Jquery_Asp.net - Fatal编程技术网

Javascript 如何使用此代码过滤网格的所有列?

Javascript 如何使用此代码过滤网格的所有列?,javascript,jquery,asp.net,Javascript,Jquery,Asp.net,我在网格视图中使用了这段代码,但它只是过滤了一段代码 我的网格视图的列。 我想将其他列添加到此代码中,我将其用于循环,但代码无法正常工作 如何更改此代码以在其他列而不是一列中实现过滤 有一列筛选代码: $(document).ready(function () { // // Client Side Search (Autocomplete) // Get the search Key from the TextBox

我在网格视图中使用了这段代码,但它只是过滤了一段代码 我的网格视图的列。 我想将其他列添加到此代码中,我将其用于循环,但代码无法正常工作

如何更改此代码以在其他列而不是一列中实现过滤

有一列筛选代码:

 $(document).ready(function () {
            //
            // Client Side Search (Autocomplete)
            // Get the search Key from the TextBox
            // Iterate through the 1st Column.
            // td:nth-child(1) - Filters only the 1st Column
            // If there is a match show the row [$(this).parent() gives the Row]
            // Else hide the row [$(this).parent() gives the Row]
          { $('#filter').keyup(function (event) {
                var searchKey = $(this).val();

                $("#gvwHuman_ctl00 tr td:nth-child(4)").each(function () {
                    var cellText = $(this).text();
                    if (cellText.indexOf(searchKey) >= 0) {
                        $(this).parent().show();
                    }
                    else {
                        $(this).parent().hide();}

                });

            });

        });
所有列都有代码:

 $(document).ready(function () {
            //
            // Client Side Search (Autocomplete)
            // Get the search Key from the TextBox
            // Iterate through the 1st Column.
            // td:nth-child(1) - Filters only the 1st Column
            // If there is a match show the row [$(this).parent() gives the Row]
            // Else hide the row [$(this).parent() gives the Row]
          { $('#filter').keyup(function (event) {
                var searchKey = $(this).val();
              for(i=0;i<5;++i)
               {    $("#gvwHuman_ctl00 tr td:nth-child(i)").each(function () {
                    var cellText = $(this).text();
                    if (cellText.indexOf(searchKey) >= 0) {
                        $(this).parent().show();
                    }
                    else {
                        $(this).parent().hide();}

                });

            });   }

        });
$(文档).ready(函数(){
//
//客户端搜索(自动完成)
//从文本框中获取搜索键
//遍历第1列。
//td:n子项(1)-仅过滤第1列
//如果存在匹配项,则显示该行[$(this).parent()给出该行]
//Else隐藏行[$(this).parent()给出行]
{$('#filter').keyup(函数(事件){
var searchKey=$(this.val();
对于(i=0;i=0){
$(this.parent().show();
}
否则{
$(this.parent().hide();}
});
});   }
});
替换此:

for(i=0; i<5; ++i) {
     $("#gvwHuman_ctl00 tr td:nth-child(i)").each(function () {
对于(i=0;i替换此:

for(i=0; i<5; ++i) {
     $("#gvwHuman_ctl00 tr td:nth-child(i)").each(function () {

for(i=0;iit也不正常工作我测试你的代码它只是过滤我的最后一列网格任何人都知道其他事情我想我必须使用这样的东西$(“#gvwHuman_ctl00 thead tr:nth child(i)”)。每个(函数(){我不知道这是真的吗?我想过滤网格的所有列它也不能正常工作我测试你的代码它只是过滤我的网格的最后一列任何人都知道其他事情我想我必须使用这样的东西$(“#gvwHuman_ctl00 thead tr:nth child(i)”)。每个(函数(){我不知道它是真的吗?我想过滤网格的所有列