JavaScript的隐藏多个gridview的行 [英] javascript hide multiple gridview rows
本文介绍了JavaScript的隐藏多个gridview的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
DropDownList的项目
DropDownList items
a
b
c
GridView控件
GridView
X | B | C | D | E
a | 1 | 2 | 3 | 4
b | 2 | 2 | 2 | 2
c | 3 | 3 | 3 | 3
在 DropDownList.SelectedItem
= A
隐藏 GridView.Rows
= B
&安培; C
Hide GridView.Rows
= b
& c
在 DropDownList.SelectedItem
= B
隐藏 GridView.Rows
= A
&安培; C
Hide GridView.Rows
= a
& c
等
任何人都知道的JavaScript这样做的客户端?
Anyone know the javascript for doing this client-side?
推荐答案
假设DropDownList的id是字母
和GridView的 TBL
,你可以这样来做:
Assuming the dropdownlist's id is alpha
and the gridview's tbl
, you can do it this way:
$(document).ready(function(){
$("#alpha").change(function(){
var selVal = $(this).find(":selected").text();
var rows = $("#tbl tr:gt(0)");
if (selVal == "ALL") {
$("#tbl tr").show();
}
else {
var rowToShow = rows.find("td:eq(0)").filter(":contains(" + selVal + ")").closest("tr");
rows.show().not( rowToShow ).hide();
}
});
});
下面是 JS BIN为例
这篇关于JavaScript的隐藏多个gridview的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文