SCRIPT LANGUAGE=JScript RUNAT=SERVER>
//--------------------------------------------------------------------
// ThreadTree
//
// Copyright (c) 2000 Paul Welter
//
// Builds a Threaded Tree from a recordset. This function does a callback
// to DisplayTree(oFilterRS, blnHasChild, intCurrentDepth). You
// must implement this function for this function to work.
//
//--------------------------------------------------------------------
function ThreadTree(objRS, strRef, intDepth, strColMsgID, strColRefID)
{
intDepth++
var objThreadRS = null;
if (intDepth < 5) {
try {
objThreadRS = objRS.clone(); //cloning curser not data
var strFilter = strColRefID + " = '" + strRef + "'"; // building filter string
objThreadRS.Filter = strFilter; //filtering
if (objThreadRS.eof) { //if no records return
objThreadRS.close();
objThreadRS = null;
return false;
}
else { //if records
while (objThreadRS.eof==false)
{
var blnHasChild
blnHasChild = ThreadTree(objRS, objThreadRS(strColMsgID).value, intDepth, strColMsgID, strColRefID); //looking for child
DisplayTree(objThreadRS, blnHasChild, intDepth); //do display here
objThreadRS.movenext();
}
objThreadRS.close();
objThreadRS = null;
return true;
}
}
catch(objError) {
if (objThreadRS != null) {
if (objThreadRS.state != 0) { objThreadRS.close(); objThreadRS = null; }
}
LogError(objError, "ThreadTree");
return false;
}
}
else {
return false;
}
}
</SCRIPT>