JQuery插件-多选(适用于GridView,DataList,Repeater以及其他)

 

JQuery是一个非常强大的JavaScript Framework,用它可以更方便的查找,操作html元素。尤其是提供了ready事件,从此不再为body的onload事件而郁闷不已。现在介绍一下用法:

MultiSelect : function(container, header, item, target)
当点击checkbox时调用这个方法,其中参数
container:容器的ID,如果使用母版页请用ClientID
header:HeaderTemplate中全选checkbox的ID
item:ItemTemplate中的checkbox,包括id(checkbox的ID),key(关键字属性,一般使用checkbox的title属性),type(关键字类型,设置number表示数字,否则表示字符)
target:存放所选checkbox的控件,一般使用HiddenField

Refresh : function(container, header, item, target)

分页时刷新checkbox的选择状态,参数同上

示例如下:

$(
        
function ()
        
{
            $().Refresh(
"GridView1""Header"{id: "Item", key: "title", type: ""}"ID");
            
            $(
"input[@type='checkbox']").click(
                
function()
                
{
                    $(
this).MultiSelect("GridView1""Header"{id: "Item", key: "title", type: ""}"ID");
                }
);
        }
);

< asp:GridView ID = " GridView1 "  runat = " server "  AutoGenerateColumns = " False "  DataKeyNames = " CategoryID "
                DataSourceID
= " SqlDataSource1 "  AllowPaging = " True "  PageSize = " 5 " >
                
< Columns >
                    
< asp:TemplateField >
                        
< HeaderTemplate >
                            
< input id = " Header "  type = " checkbox "  title = " 全选 "   />
                        
</ HeaderTemplate >
                        
< ItemTemplate >
                            
< input id = " Item "  type = " checkbox "  title = " <%# Eval( " CategoryID " ) %> "   />
                        
</ ItemTemplate >
                    
</ asp:TemplateField >
                    
< asp:BoundField DataField = " CategoryID "  HeaderText = " CategoryID "  InsertVisible = " False "
                        ReadOnly
= " True "  SortExpression = " CategoryID "   />
                    
< asp:BoundField DataField = " CategoryName "  HeaderText = " CategoryName "  SortExpression = " CategoryName "   />
                    
< asp:BoundField DataField = " Description "  HeaderText = " Description "  SortExpression = " Description "   />
                
</ Columns >
            
</ asp:GridView >
< asp:HiddenField ID = " ID "  runat = " server "   />


/Files/Zane/MultiSelect.rar

 

<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值