Javascript Error

I Have a Rad Treeview with checkboxes enabled and with a JavaScript that "checks" the parent and it's group if a child node is checked...(See Code).
Works fine...

If I click a "top" parent item I get a java error...of course.

I need to change the script so that if the parent is checked all children get checked and keep the same script that is working now.
<telerik:RadTreeView runat="server" ID="RadTreeView1" DataSourceID="SqlDataSource1"
                    DataFieldID="id" DataFieldParentID="parentID" CheckBoxes="true" CheckChildNodes="true"
                        <telerik:RadTreeNodeBinding TextField="panelText" ValueField="id" />
                        <telerik:RadTreeNodeBinding Depth="0" Checkable="True" TextField="panelText" ValueField="id"
                            Expanded="true" />

--Java Script
 <script type="text/javascript">
        function checkChange(sender, args) {
            var checkedNode = args.get_node();
            if (checkedNode.get_checked()) {

Open in new window

Larry Bristersr. DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

As for your error - simply check if this is not the top:
(checkedNode.get_parent() == checkedNode.get_treeView())
(checkedNode.get_level() == 0)  
before calling set_checked()
This will make sure that you do not call illegal methods (if I remember my syntax properly that is)

Do you need any help on the other part (set all children as checked)?
Larry Bristersr. DeveloperAuthor Commented:
Sorry...but I don't know how that would look or be palced in my JavaScript above.
if (checkedNode.get_parent() != checkedNode.get_treeView()) {

PS:  for exact syntax and the second choice

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Larry Bristersr. DeveloperAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.