选中/取消选中所有Radlistview包含单击按钮时的复选框列表

时间:2014-01-24 08:56:55

标签: javascript jquery asp.net

我想按钮点击检查/取消选中所有复选框客户端。 我的代码是

<asp:Button ID="btn_select" runat="server" Text="Select All Checkbox" UseSubmitBehavior="false"></asp:Button>
<telerik:RadListView ID="RadListView_Permission" runat="server" AllowCustomPaging="true" AllowPaging="True" onitemdatabound="RadListView_Permission_ItemDataBound">
    <ItemTemplate>
        <div style="border:1px solid gray;">
            <table width="100%">
                <tr>
                    <td width="5%"></td>
                    <td class="LabelWidth">
                        <div>
                            <asp:Label ID="Label4" runat="server" Text='<%# (DataBinder.Eval(Container.DataItem, "PermissionItemName")) %>'></asp:Label>
                        </div>
                    </td>
                    <td style="margin:2%; width:70%;">
                        <%-- <div class="checkbox-list">
                            <label class="checkbox-inline">--%> <span style=" margin:2%;width:50%; text-align:left; "><asp:CheckBoxList RepeatDirection="Horizontal" AutoPostBack="false" CellPadding="5" CellSpacing="7"  RepeatLayout="Table"  ID="Listbox_Permission" runat="server" DataTextField="PermissionOperationName" DataValueField="PermissionItemOpearationId"  CssClass="checkbox-inline checkbox-list" >    </asp:CheckBoxList></span>

                                <%-- </label>
        </div>--%></td>
        </tr>
        </table>
        </div>
    </ItemTemplate>
</telerik:RadListView>

1 个答案:

答案 0 :(得分:0)

这样做:

<input type="button" class="check" value="check all" />
<input type="checkbox" class="cb-element" /> Checkbox  1
<input type="checkbox" class="cb-element" /> Checkbox  2
<input type="checkbox" class="cb-element" /> Checkbox  3

$('.check:button').toggle(function(){
    $('input:checkbox').attr('checked','checked');
    $(this).val('uncheck all')
},function(){
    $('input:checkbox').removeAttr('checked');
    $(this).val('check all');        
})

从这里采取:jquery check uncheck all checkboxes with a button

Fiddle