DropDownList项目
a
b
c
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
当DropDownList.SelectedItem
= b
隐藏GridView.Rows
= a
& c
等等
任何人都知道这个客户端的javascript吗?
答案 0 :(得分:2)
假设下拉列表ID为alpha
和gridview tbl
,您可以这样做:
$(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
中的示例答案 1 :(得分:0)
在下面分享一个子伪代码:
Array listFromGridView = [a,b,c];
// get parent dropdownbox and save for future reference
var drop=$("#dropdownBoxID);
drop.bind('click',function(e){
// get all element in an array
Array tempList= listFromGridView;
// remove the element which was clicked
// $(this) = the dropdownbox, $(this).val() = selected value
tempList.remove( $(this).val() );
// iterate and hide rows
foreach( element el in tempListView)
// code for hide goes here
});
// Done :-)