This is a migrated thread and some comments may be shown as answers.

Disabling checkbox for an enabled node

3 Answers 126 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
SomeName
Top achievements
Rank 1
SomeName asked on 07 Jul 2011, 08:55 AM
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?

3 Answers, 1 is accepted

Sort by
0
Accepted
Plamen
Telerik team
answered on 12 Jul 2011, 04:07 PM
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!

0
SomeName
Top achievements
Rank 1
answered on 13 Jul 2011, 06:48 AM

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.

0
Plamen
Telerik team
answered on 13 Jul 2011, 12:44 PM
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!

Tags
TreeView
Asked by
SomeName
Top achievements
Rank 1
Answers by
Plamen
Telerik team
SomeName
Top achievements
Rank 1
Share this question
or