Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 6th, 2004, 09:53 AM
Rich's Avatar
Rich Rich is offline
Administrator
Developer Shed Admin.
 
Join Date: Sep 2003
Location: Fort Lauderdale, FL
Posts: 152 Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 11 h 47 m 28 sec
Reputation Power: 10
Remote Scripting to dynamically add the leaves to a Tree Control

This Demo uses remote scripting to dynamically add the leaves. i.e. it loads the root items first then loads the child items when you expand the parent item. Note:that with the remote scripting samples there is a hard-coded path to the relevant support files, this will have to be changed appropriatel ...
This Demo uses remote scripting to dynamically add the leaves. i.e. it loads the root items first then loads the child items when you expand the parent item. Note:that with the remote scripting samples there is a hard-coded path to the relevant support files, this will have to be changed appropriately for people to get the demos to work on their own system.

First Page--RSTreeView.htm

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>TreeView using Remote Scripting</TITLE>
</HEAD>
<BODY>
<!-- Author: Adrian Forbes -->
<script language="JavaScript" src="../_scriptlibrary/rs.htm"></script>
<script language="JavaScript">RSEnableRemoteScripting("../_scriptlibrary");</script>

<OBJECT ID="tvwTree" WIDTH=300 HEIGHT=276
CLASSID="CLSID:0713E8A2-850A-101B-AFC0-4210102A8DA7">
<PARAM NAME="_ExtentX" VALUE="7938">
<PARAM NAME="_ExtentY" VALUE="7303">
<PARAM NAME="_Version" VALUE="327682">
<PARAM NAME="Indentation" VALUE="0">
<PARAM NAME="LabelEdit" VALUE="1">
<PARAM NAME="LineStyle" VALUE="1">
<PARAM NAME="Style" VALUE="7">
<PARAM NAME="Appearance" VALUE="1">
</OBJECT>
<p>
<input type=BUTTON onClick="SubmitNode();" value="Select" id=BUTTON1 name=BUTTON1>
</p>
<form name=frmTree action="TreeControlTarget.asp" method=GET>
<input type=HIDDEN name=txtSelected>
</form>

<script language=VBScript>
strDBPage = "RSDatabase.asp"
tvwChild = 4

sub window_onLoad
LoadParents
end sub

function LoadParents

set objRS = RSExecute(strDBPage ,"GetDBParents")
sRS = objRS.return_value
aRows = Split(sRS, Chr(13))

tvwTree.Nodes.Clear

for i = 0 to UBound(aRows) - 1
aFields = Split(aRows(i), ";")
Set tmpNode = tvwTree.Nodes.Add(, , "P" & aFields(0), aFields(1))
tvwTree.Nodes.Add tmpNode, tvwChild, , "DUMMY"
next

end function

Sub tvwTree_Expand(ByVal Node)
dim tmpRS, lHeaderID
dim sOld, sNew

If Node.Child.Text <> "DUMMY" Then
exit sub
end if

tvwTree.Nodes.Remove Node.Child.Index

lID = mid(node.Key, 2)
set objRS = RSExecute(strDBPage ,"GetDBChildren", lID)
sRS = objRS.return_value
aRows = Split(sRS, Chr(13))

for i = 0 to UBound(aRows) - 1
aFields = Split(aRows(i), ";")
tvwTree.Nodes.Add Node, tvwChild, "C" & aFields(0), aFields(1)
next

End Sub

sub SubmitNode
if document.tvwTree.selecteditem is nothing then
msgbox "Select an item from the tree"
else
document.frmTree.txtSelected.value = document.tvwTree.selecteditem.text
document.frmTree.submit
end if
end sub
</script>

</BODY>
</HTML>

Page 2 RSDatabase.asp

<%@ LANGUAGE=VBSCRIPT %>
<%
strconn = "Driver={SQL Server};Description=sqldemo;SERVER=127.0.0.1;UID=L oginID;PWD=Password;DATABASE=Database_Name
%>
<% RSDispatch %>
<!-- Author: Adrian Forbes -->
<!--#INCLUDE FILE="../_ScriptLibrary/rs.asp"-->
<SCRIPT RUNAT=SERVER Language=javascript>
function Description()
{
this.GetDBParents = Function( 'return GetDBParents()' );
this.GetDBChildren = Function('ID', 'return GetDBChildren(ID)' );
this.Method1 = Method1;
}
public_description = new Description();

function Method1()
{
return 'Test';
}
</script>

<SCRIPT RUNAT=SERVER Language=VBScript>
function GetDBParents()

set objRS = createobject("ADODB.Recordset")
objRS.Open "select ID, strParent from Parents", strconn
GetDBParents = objRS.GetString(, , ";")
objRS.Close
set objRS.ActiveConnection = nothing
set objRS = nothing

end function

function GetDBChildren(ID)

set objRS = createobject("ADODB.Recordset")
objRS.Open "select ID, strChild from Children WHERE intParent=" & ID, strconn
GetDBChildren = objRS.GetString(, , ";")
objRS.Close
set objRS.ActiveConnection = nothing
set objRS = nothing

end function
</SCRIPT>

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Remote Scripting to dynamically add the leaves to a Tree Control


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT