グリッド ビューのすべての列をテキスト ボックスでフィルター処理するためにこのコードを試しましたが、グリッドの最後の列をフィルター処理するだけです。どうすれば変更できますか?私のコードで何が間違っていますか? 私の最初の列は 2 で、最後の列は 4 です。私の for ループは 2 で始まり、4 で終わりましたが、この ""(i=2;i<4;i++) を試すと、インデックスが 3 の列が表示されます。
$(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 =2; i<5; i++) {
$("#gvwHuman_ctl00 tr td:nth-child(" + i + ")").each(function () {
// $("#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();
}
});
}
});
});