Obout Treeview - Reverse sort

Discussion in 'ASP.NET WebServices' started by bluebeard96, May 30, 2004.

  1. I am posting this for anyone who is interested in reverse tree views with the Obout Treeview component (using standard ASP, not .Net).

    After playing with the ASP Treeview component for a while, I decided to create a photo album for my Kiwanis Club. I thought it would be ideal to show the folders in my root directory in reverse order. My folder names would start with the year, month, and day (ie "2004-05-24 ~ Governor's Visit") so the resulting display of folders would show the most recent folder on top, with the actual files still in alphabetical order.

    So I copied the AddFolder function and modified it as a new AddFolderReverse function. There might be a more programatically correct way of doing this, but what I made works great for those that may want to show root folders (or all folders) in reverse order.

    I modified this line:
    Call AddFolder(sPath, "../" & Escape(sFolderName), "root")</font id="blue">

    to read as such:
    Call AddFolderReverse(sPath, "../" & Escape(sFolderName), "root")</font id="blue">


    And added the below function:
    Function AddFolderReverse(pth, dpt, parentID)
    Dim oF, oFolder, oFile, oSubFolder, oItem, myReverseArrayName(), myReverseArrayPath()

    Set oFolder = oFSO.GetFolder(pth)
    Set oSubFolder = oFolder.SubFolders
    Set oFile = oFolder.Files

    REDIM myReverseArrayName(oSubFolder.Count)
    REDIM myReverseArrayPath(oSubFolder.Count)
    oSubFolderPosition = 1

    For Each oItem In oSubFolder
    myReverseArrayName(oSubFolder.Count-oSubFolderPosition) = oItem.Name
    myReverseArrayPath(oSubFolder.Count-oSubFolderPosition) = oItem.Path
    oSubFolderPosition = oSubFolderPosition + 1
    Next

    For i = 0 to (oSubFolder.Count-1)
    iNode = iNode + 1
    ot.Add parentID, "z" & iNode, "<span onclick='ob_os(this)'> " & myReverseArrayName(i) & "</b></span>"
    Call AddFolder(myReverseArrayPath(i), dpt & "/" & Escape(myReverseArrayName(i)), "z" & iNode)
    ' To show all subfolders in reverse order, simply replace the above line with this line:
    'Call AddFolderReverse(myReverseArrayPath(i), dpt & "/" & Escape(myReverseArrayName(i)), "z" & iNode)
    Next

    ' Display Files.

    For Each oF In oFile
    iNode = iNode + 1
    ot.Add parentID, "z" & iNode, " <a href='" & dpt & "/" & Escape(oF.Name) & "' target=kphm>" & oF.Name & "</b></a>", , "red_ball.gif"
    Next
    End Function</font id="blue">


    Watch for extra line breaks in the code. Hope someone else might be able to put this to good use.


    Mike Reilly, Webmaster
    Kiwanis Club of Rancho Peñasquitos
    [email protected]
     

Share This Page