Home   Free Applications   Code Snippets   Fun Stuff 
 
 You are here: Home > Code Snippets > ASP
Register   Login  

 
Site Navigation


Print Print this page
Email E-mail this page
Bookmark Add to Favorites

 
Tree Builder - JScript

Posted by on Friday, October 17, 2003 (EST)

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.
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>

Comments:

wwew
By ? on Friday, November 25, 2005 (EST)
wwww

Reply to this Comment

Add Your Comment



Top