Disabling checkbox for an enabled node

4 posts, 1 answers
  1. SomeName
    SomeName avatar
    19 posts
    Member since:
    Jul 2011

    Posted 07 Jul 2011 Link to this post

    Refering to this thread i have an aditional question, hope you can help:
    http://www.telerik.com/community/forums/preview-thread/aspnet/treeview/disabling-checkbox-for-an-enabled-node.aspx


    I'd like to have the same feature with threestatecheckbox enabled, how can i achieve this?

  2. Answer
    Plamen
    Admin
    Plamen avatar
    3031 posts

    Posted 12 Jul 2011 Link to this post

    Hello,

    Unfortunately the three state checkbox do not have disable or readonly states by default.

    You can try a workaround with the background image like here:
    function OnClientLoad(sender) {
             var $ = $telerik.$;
             var tri = $(".DisabledCheckBox", sender.get_element()).siblings(".rtUnchecked");
             tri.unbind("click");
             tri.css("background-image", "url(/Images/3-state-checkbox-disabled.gif)");
             tri.click(function () {
                 return false;
             });
    I am attaching the image that is used.

    Hope this  will help you.

    Greetings,
    Plamen Zdravkov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. SomeName
    SomeName avatar
    19 posts
    Member since:
    Jul 2011

    Posted 13 Jul 2011 Link to this post

    Thanks for the answer.

    Your Code doesnt work 100% for me, but it helped me alot.

    1.) It only works for checkboxes that get populated as unchecked because of
    var tri = $(".DisabledCheckBox", sender.get_element()).siblings(".rtUnchecked");
    2.) I had to swap the checked and unchecked states from your image, because it got loaded wrongly. (Image is attached)

    To fix the first point i have modified your code to the following: (improvements are welcome)

    function OnClientLoad(sender) {
    var $ = $telerik.$;
    var arrState = new Array(".rtUnchecked", ".rtChecked", ".rtIndeterminate");
    for (var i = 0; i < arrState.length; i++) {
    var tri = $(".DisabledCheckBox", sender.get_element()).siblings(arrState[i]);
    if (tri != null) {
    tri.css("background-image", "url(../Images/3-state-checkbox-disabled.gif)");
    tri.unbind("click");
    tri.click(function () {
    return false;
    });
    }
    }
    }

    And added the same function to OnClientNodePopulated in my treeView.

    <telerik:RadTreeView ID="treeView1" runat="server" OnClientNodePopulated="OnClientLoad" OnClientLoad="OnClientLoad">
    </telerik:RadTreeView>

    Also i'd like to mention, that this feature was wished for in May 17, 2005. So, i hope it will be added some day.
    More than 6 Years is a really long time.

  4. Plamen
    Admin
    Plamen avatar
    3031 posts

    Posted 13 Jul 2011 Link to this post

    Hello,

    Please, excuse us for the inconvenience. Thank you for the feedback and for reminding us this feature.

    Regards,
    Plamen Zdravkov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top