不能够检查并取消复选框的radcombox内 [英] Not able to check and uncheck the checkboxes inside the radcombox

查看:127
本文介绍了不能够检查并取消复选框的radcombox内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的 Telerik的radcombobox控件并在 radcombobox控件我使用一些复选框是这样的:

I am using telerik Radcombobox and in that radcombobox i am using some checkbox like this:

但我不能够检查并取消其是radcombox内的复选框。

But i am not able to check and uncheck the checkboxes which are inside the radcombox.

<telerik:RadComboBox ID="rad1" runat="server" Width="200" Font-Names="Arial" DropDownWidth="460"
        AutoPostBack="true" EmptyMessage="Select Action Type(s)" EnableScreenBoundaryDetection="false" OffsetX="-0">
            <HeaderTemplate>
                  <div class="header">
                             <asp:CheckBox ID="selectAll" CssClass="All" runat="server" Text="Select All" />
                    </div>

                   ---------Section 1 -----------
     <ul>
    <div id="section1" class="section">
                 <li class="carousel-border">
                       <asp:CheckBox ID="chkParent1" CssClass="section1parent" runat="server" Text="Check All" /> --Parent of below 2 checkboxes
                  </li>
                   <li>
                        <asp:CheckBox ID="chkchild1" CssClass="section1child" runat="server" Text="Child 1" />
                    </li>
                      <li>
                           <asp:CheckBox ID="chkchild2" CssClass="section1child" runat="server" Text="Child 2" />
                      </li>                                
           </div>

---------Section 2 -----------
    <div id="section2" class="section">
                 <li class="carousel-border">
                       <asp:CheckBox ID="chkParent2" runat="server" Text="Check all" /> --Parent of below 2 checkboxes
                  </li>
                   <li>
                        <asp:CheckBox ID="chkchild3" runat="server" Text="Child 3" />
                    </li>
                      <li>
                           <asp:CheckBox ID="chkchild4" runat="server" Text="Child 4" />
                      </li>                                
           </div>
           </ul>

             </HeaderTemplate>
  </telerik:RadComboBox>

--This is for section 1----
 This is on check of section1 CheckAll 


 $("#section1 .section1parent").change(function () {
                    $(this).closest('.section').find(':checkbox').prop('checked', this.checked);
                });

但我的两个复选框即 chkchild1 chkchild2 没有得到确认。

我想原因可能是查找功能心不是能够找到的复选框的复选框,因为正在radcombox。

I guess the reason could be the find function isnt able to find the checkbox as because checkbox are under radcombox.

任何人能告诉我,为什么发生这种情况和最新的这个解决方案?

Can anybody tell me why this is happening and whats the solution for this??

推荐答案

在没有看到输出HTML,它几乎是不可能的,看看这是怎么了。我会检查你的HTML code的(确保一切都被关闭)的有效性。它在测试场景中的伟大工程的是:

Without seeing the output HTML, it is nearly impossible to see where this is going wrong. I would check the validity of your HTML code (make sure everything is closed). It works great in a test scenario as is:

https://jsfiddle.net/9ryeqgn7/

$(function () {
            $("#section1 .section1parent").change(function () {
                $(this).closest('.section').find(':checkbox').prop('checked', this.checked);
            });
        });

在我看来,你拥有了一切正确的,甚至因为它是一个Telerik的控制。

As I see it, you have everything correct, even given that it is a Telerik control.

您可能想换行功能在$(函数(){})只是为了确保它运行后的DOM完全加载(见小提琴)。

You may want to wrap the function in a $(function(){}) just to make sure it runs after the DOM is completely loaded (see fiddle).

哇,它越来越难以与发布code的东西和链接,这些天...

Wow, it's getting hard to post things with code and links these days...

顺便说一句,从一个HTML的角度来看,我不喜欢埋在UL的做法股利,但我看到你做了什么那里。也许不是的div,你可以使用一个类里的每个组认为它们放在一起?

As an aside, from an html perspective, I don't like the div buried in the ul approach, but I see what you did there. Perhaps instead of the div, you could use a class for each li that groups them together?

这篇关于不能够检查并取消复选框的radcombox内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆