我的 aspx 页面上有网格视图,如果用户键入表格中的数据,它会过滤网格视图,我的网格视图上方有文本框。我想遍历我的网格的每个单元格并检查值是否相同显示它,如果不隐藏它。现在我有一个代码,它可以通过一列来完成这项工作,它在一列中遍历所有行。我想更改这段代码,我可以遍历它的所有列和所有行。如果有人知道如何请帮助我
$(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();
var a = $('#gvwHuman_ctl00');
var b = a.attr.length;
$("#gvwHuman_ctl00 tr td:nth-child("2")").each(function () {
var cellText = $(this).text();
if (cellText.indexOf(searchKey) >= 0) {
$(this).parent().show();
}
else {
$(this).parent().hide();
}
});
});
});
及其我的表结构我使用 rad grid Telerik 组件,但它与网格视图相同
<table id="gvwHuman_ctl00" class="rgMasterTable rgClipCells" border="0" style="width:100%;table-layout:fixed;overflow:hidden;empty-cells:show;">
<colgroup>
<thead>
<tr>
<th class="rgResizeCol rgHeader" scope="col"> </th>
<th class="rgHeader" scope="col" title="Drag to group or reorder" style="cursor: move;">کد</th>
<th class="rgHeader" scope="col">
<a href="javascript:__doPostBack('gvwHuman$ctl00$ctl02$ctl01$ctl00','')" title="Click here to sort">نام</a>
</th>
<th class="rgHeader" scope="col">
<a href="javascript:__doPostBack('gvwHuman$ctl00$ctl02$ctl01$ctl01','')" title="Click here to sort">هزینه</a>
</th>
</tr>
<tr class="rgFilterRow" style="font-family: Tahoma; display: none;">
</thead>
<tfoot>
<tr class="rgPager" valign="middle" style="font-family: Tahoma;">
<td colspan="4">
<table border="0" style="width:100%;border-spacing:0;" summary="Data pager which controls on which page is the RadGrid control.">
<caption>
<thead>
<tbody>
<tr>
<td class="rgPagerCell NextPrevAndNumeric">
<div class="rgWrap rgArrPart1">
<div class="rgWrap rgNumPart">
<div class="rgWrap rgArrPart2">
<div class="rgWrap rgAdvPart">
<span id="gvwHuman_ctl00_ctl03_ctl01_ChangePageSizeLabel" class="rgPagerLabel">سایز صفحه</span>
<div id="gvwHuman_ctl00_ctl03_ctl01_PageSizeComboBox" class="RadComboBox RadComboBox_WebBlue RadComboBox_rtl RadComboBox_WebBlue_rtl" style="width:46px;">
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tfoot>
<tbody>
</table>