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

Checkboxes in Tree Acting Like Radio Buttons

3 Answers 88 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Marbry
Top achievements
Rank 1
Marbry asked on 27 Jan 2012, 04:50 PM
I have a treeview with a number of nodes that contain various editing controls that are generated from templates.  The problem is that the checkboxes are being treated like radio buttons as it will only allow one at a time to be checked.  When I check one, it appears the tree automatically unchecks any others in the entire tree, firing the checkchanged handler for each in its template.

This only seems to be exhibited when a checkbox is clicked, I can generate the tree with multiple check boxes checked, but as soon as you check one I see this behavior.

All the checkboxes have unique ID's.

When I place several checkboxes on the same page with their own checkchanged handlers, but outside of the tree, they do not demonstrate this behavior amongst themselves.  Although even checking one of these, the ones in the tree do.

I added some code to the checkchanged handlers in the templates and checked the __EVENTTARGET param and kicked it out of any that didn't match the ID of the sender.  This kept the underlying data correct, but when the page regenerates all the other checkboxes are still unchecked.  This would seem to imply that the tree is somehow forcing this on the controls when they're rendered.

If not I don't know where else this would be coming from.  Any insight is appreciated though.

3 Answers, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 30 Jan 2012, 06:36 PM
Hi Marbry,

Unfortunately the information provided isn't enough to troubleshoot the problem. Could you try to simplify the markup of your page and paste it here, or try to open a support thread and isolate the problem in a sample project and attach it there. 
 
All the best,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Marbry
Top achievements
Rank 1
answered on 30 Jan 2012, 07:40 PM
The tree content is all generated in code.  I'll see if I can put something together that replicates the problem.
0
Bozhidar
Telerik team
answered on 31 Jan 2012, 03:01 PM
Hi,

Just to notify anyone else, that may come across this issue. I've inspected the code provided by Marbry and it turns out that he was disabling the checkboxes. When the ASP CheckBox control is disabled, it's checked state is not stored in the viewstate, wich is why on every postback they appear unchecked. To overcome this behavior, you have to use either a hidden field, or some other mechanism to store the checked state of the checkbox, and then reproduce it when the page is loaded.
 
Greetings,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
TreeView
Asked by
Marbry
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Marbry
Top achievements
Rank 1
Share this question
or