<br><%@ Page Language="C#" AutoEventWireup="true" CodeFile="JqueryTableFilter.aspx.cs" Inherits="JqueryTableFilter" %> <img src="http://files.jb51.net/upload/201007/20100726123453506.gif" border="0" alt="tables_jquery의 간단한 필터링을 구현하기 위한 JQuery 기반 코드 문장" ><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br><html xmlns="http://www.w3.org/1999/xhtml"> <br><head runat="server"> <div class="codetitle"><제목></제목> <span><script src="Script/jquery-1.3.2-vsdoc.js" type="text/javascript"></script> <a style="max-width:90%" data="13514" class="copybut" id="copybut13514" onclick="doCopy('code13514')"><script type="text/javascript"> <u>$(function() { </u>$("#Text1").keyup(function() { </a>var filterText = $(this).val(); </span>$("#< %=GridView1.ClientID %> tr").not(":first").hide().filter(":contains('" filterText "')").show();; </div>}). 키업() <div class="codebody" id="code13514">}); <br></script> <br></head> <br><본문> <br><form id="form1" runat="server"> <br><div style="width:60%;"> <br><input id="Text1" type="text" /> <br><asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" <BR>DataKeyNames="OrderID" DataSourceID="SqlDataSource1" <BR>HorizontalAlign="Left" PageSize="50" > ; <BR><열> <br><asp:BoundField DataField="OrderID" HeaderText="OrderID" ReadOnly="True" <BR>SortExpression="OrderID" InsertVisible="False" /> <br><asp:BoundField DataField="CustomerID" HeaderText="CustomerID" <BR>SortExpression="CustomerID" /> <br><asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" <BR>SortExpression="EmployeeID" /> <br><asp:BoundField DataField="OrderDate" HeaderText="OrderDate" <BR>SortExpression="OrderDate" /> <br><asp:BoundField DataField="RequiredDate" HeaderText="RequiredDate" <BR>SortExpression="RequiredDate" /> <br><asp:BoundField DataField="ShippedDate" HeaderText="ShippedDate" <BR>SortExpression="ShippedDate" /> <br><asp:BoundField DataField="ShipVia" HeaderText="ShipVia" <BR>SortExpression="ShipVia" /> <br><asp:BoundField DataField="Freight" HeaderText="Freight" <BR>SortExpression="Freight" /> <br></열> <br></asp:GridView> <br><asp:SqlDataSource ID="SqlDataSource1" runat="server" <BR>ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" <br>SelectCommand="[주문]에서 상위 50개 * 선택"></asp:SqlDataSource> <br></div> <br></form> <br></body> <br></html> <br><br> <br>JQuery代码就: <br><br><br><br><br>复代码<br><br><br> 代码如下:<br><br> <br>$(function() { </div>$("#Text1").keyup(function() { <br>var filterText = $(this).val(); <br>$("#<%= GridView1.ClientID %> tr").not(":first").hide().filter(":contains('" filterText "')").show();; <div class="codetitle">}).keyup( ) <span>}); <a style="CURSOR: pointer" data="5228" class="copybut" id="copybut5228" onclick="doCopy('code5228')"><u> </u></a>지역 JQuery의 选择器: </span> </div>1:$("#<%=GridView1.ClientID %> tr")选择表格的所有行; <div class="codebody" id="code5228">2:not(":first"):除去第一行表头行; <br>3:filter(":contains('" filterText "')"):从上面所选择的行里面筛选为文本中包含filterText 的行显示流来; <br>4:最后加一句keyup()是为了在提交后重新触发keyup事件。客户端控件没有ViewState <br>若是服务器端控件就会看见他적작업). <br><br>JQuery의 选择器的强大处, 让我们能救这么简单的实现客端的简单筛选。最后加一句关于表格筛选有JQuery插件提供 <br>给我们选择, 但是这种简单的功能,我不会去选择加入一个JavaScript文件库,呵呵。<br>작성자 : </div>破 浪<br>