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

RadTreeView checkbox how to check it automatically

2 Answers 96 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 15 Jul 2011, 01:58 PM

Hi,

I have to use VBScript and have to check the checkbox automatically, I mean, do smth like this:
doc.GetElementById("ResetPasswordCheckBox").Checked = True or
doc.GetElementById("saveBtn").Click
etc. where doc = ie.document

But when I try to implement these sentences, nothing works:

doc.GetElementById("UserGroupsTree").Nodes(0).Checked
doc.GetElementById("UserGroupsTree").Nodes(1).Selected
doc.GetElementById("UserGroupsTree").Nodes(2).Selected
doc.GetElementById("UserGroupsTree").SelectedNodes.Count
doc.GetElementById("UserGroupsTree").Nodes(0).Text
doc.GetElementById("UserGroupsTree").Nodes(1).Text
doc.GetElementById("UserGroupsTree").Nodes(2).Text
doc.GetElementById("UserGroupsTree").Nodes(0).Value
doc.GetElementById("UserGroupsTree").Nodes(1).Value
doc.GetElementById("UserGroupsTree").Nodes(2).Value

The html code contains smth like this:

 

<div id="UserGroupsTree"

class="RadTreeView RadTreeView_Default"

style="overflow:auto;height:100%;width:100%;">

 

<ul class="rtUL rtLines">

<li class="rtLI rtFirst rtLast">

<div class="rtTop">

<span class="rtSp"></span>

<span class="rtPlus"></span>

<input type="checkbox" class="rtChk" />

<span class="rtIn">Some Text</span>

</div>

</li>

</ul>

<input id="UserGroupsTree_ClientState" name="UserGroupsTree_ClientState" type="hidden" />

</div>

And I want  to set this checkbox to "true" automatically, by means of script, i.e. simulating user clicking

And my script can access user machine only, no access to server side.

I 'm limited to vbscript only (script which runs on client side, not server side)

Perhaps I'm trying to do smth wrong but any help is greatly appreciated,

Thanks in advance,
John

 

2 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 20 Jul 2011, 11:17 AM

Hi,

Finally I found the solution  - how to check the checkboxes within the UserGroupsTree scope:

Dim NodeList As Variant
Set NodeList = doc.getElementById("UserGroupsTree").getElementsByTagName("input"
 For Each elem In NodeList 
        If elem.getattribute("type") = "checkbox" Then
        elem.Checked = 1 
      End If

But now there is another problem: how to expand all the nodes by means of vbscript?

Unfortunately,

set treeObj = document.getElementById("UserGroupsTree").object

does not work and I cannot do like this: treeObj.ExpandAll (as described in this article http://www.telerik.com/help/aspnet/treeview/tree_expand_client_side.html)

Is there any way to overcome this issue?

How to get the client-side instance of the treeview object by means of VBscript
like in javascript

var treeviewInstance = <%RadTreeView1.ClientID %>

Best regards,
John

0
Dimitar Terziev
Telerik team
answered on 22 Jul 2011, 01:22 PM
Hi John,

Telerik RadControls for ASP.NET AJAX are not compatible with vbscript, you should use javascript instead.

All the best,
Dimitar Terziev
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
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or