mardi 14 août 2018

Checked all the checkbox by Jquery in listview (asp.net)

I have a Listview have repeater within it, the listview is display like accordion, there are a check box , I want to check all box in repeater when click on chkSelectAll.

enter code here
   <asp:ListView ID="lstSecurityFunction" runat="server"
       OnItemDataBound="lstSecurityFucntion_OnItemDataBound">
       <LayoutTemplate>
           <ul class="nav-accordion nav-roles" style="display: block;">
               <li runat="server" id="itemPlaceholder"></li>
           </ul>
       </LayoutTemplate>
       <ItemTemplate>
           <li>
               <span class="opener" runat="server" id="liModuleName">
                   <asp:CheckBox runat="server" ID="chkSelectAll" onClick="if($(this).is(':Checked'))isClick(this);"
                       moduleId='<%#Eval("ModuleID") %>' />
                   <asp:Label runat="server"> <%#CurrentLanquage==CspPortal.CspService.NotificationLanguages.English?Eval("EnModuleName"):Eval("ArModuleName")%></asp:Label>
                   <asp:HiddenField runat="server" Value='<%#Eval("ModuleID") %>' ID="hdnModuleId"></asp:HiddenField>
                   <i class="fa fa-angle-down"></i><i class="fa fa-angle-up"></i>
               </span>

               <div class="row">
                   <asp:Repeater ID="rpSecurityFunction" runat="server">
                       <ItemTemplate>
                           <div class="col-md-3" id="list" runat="server">
                               <asp:HiddenField ID="hdnData" runat="server" />
                               <asp:CheckBox ID="cbSecruityFunction" runat="server"

                                   fucntionId='<%# Eval("FunctionID") %>'
                                   name="reason" />
                           </div>
                       </ItemTemplate>
                   </asp:Repeater>
               </div>
           </li>
       </ItemTemplate>
   </asp:ListView>

I write this jquery code

<script> function isClick(s) {
    $(".nav-roles li ").find("input[id*='chkSelectAll']").each(function () {
    var isChecked =$(this).attr("checked");
           if (this.checked) {

               $('.nav-roles li .row .col-md-3').find("input[id*='cbSecruityFunction']").each(function () {
                   $(this).prop('checked', true);
               });}
       });
} </script>




Aucun commentaire:

Enregistrer un commentaire