Skip to main content
A newer version of this page is available. .

TreeListVirtualModeCreateChildrenEventArgs.NodeObject Property

Gets the processed node object.

Namespace: DevExpress.Web.ASPxTreeList

Assembly: DevExpress.Web.ASPxTreeList.v20.2.dll

NuGet Package: DevExpress.Web

Declaration

public object NodeObject { get; }

Property Value

Type Description
Object

An object that represents the node object.

Remarks

To access the current instance of the node object, type cast the NodeObject property’s value to the type of your data.

Example

In this example, the ASPxTreeList uses the Virtual data binding method to display the file/folder tree. In this mode, a tree is created on demand.

The image below shows the result.

exVirtualMode

using System.IO;
using System.Collections.Generic;
using DevExpress.Web.ASPxTreeList;

protected void ASPxTreeList1_VirtualModeCreateChildren(object sender,
TreeListVirtualModeCreateChildrenEventArgs e) {
    string path = e.NodeObject == null ? Page.MapPath("~/") : e.NodeObject.ToString();

    List<string> children = new List<string>();
    if (Directory.Exists(path)) {
        foreach (string name in Directory.GetDirectories(path)) {
            if (!IsSystemName(name))
                children.Add(name);
        }
        foreach (string name in Directory.GetFiles(path))
            if (!IsSystemName(name))
                children.Add(name);
    }
    e.Children = children;
}
protected void ASPxTreeList1_VirtualModeNodeCreating(object sender,
TreeListVirtualModeNodeCreatingEventArgs e) {
    string path = e.NodeObject.ToString();

    e.NodeKeyValue = GetNodeGuid(path);
    e.IsLeaf = !Directory.Exists(path);
    e.SetNodeValue("FileName", PopFileName(path));
}

// Helpers

Guid GetNodeGuid(string path) {
    if (!Map.ContainsKey(path))
        Map[path] = Guid.NewGuid();
    return Map[path];
}
Dictionary<string, Guid> Map {
    get {
        const string key = "DX_PATH_GUID_MAP";
        if (Session[key] == null)
            Session[key] = new Dictionary<string, Guid>();
        return Session[key] as Dictionary<string, Guid>;
    }
}
string PopFileName(string path) {
    return path.Substring(1 + path.LastIndexOf("\\"));
}
bool IsSystemName(string name) {
    name = PopFileName(name).ToLower();
    return name.StartsWith("app_") || name == "bin"
        || name.EndsWith(".aspx.cs") || name.EndsWith(".aspx.vb");
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the NodeObject property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also