Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxDataMappingBase<TModel>.Level Property

Specifies the item level for which data mappings are applied.

Namespace: DevExpress.Blazor.Base

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[DefaultValue(-1)]
[Parameter]
public int Level { get; set; }

#Property Value

Type Default Description
Int32 -1

The item level for which mappings are applied.

#Remarks

Use the Level property to define different data mappings for different levels of component items.

The property’s default value is -1. In this case, data mappings are applied to all item levels. If you set the property to 0, mappings are applied to the root items only. If the property is set to 1, mappings are applied to the root items’ children.

The following code snippet specifies different data mappings for different TreeView levels.

Razor
<DxTreeView Data="@Data">
    <DataMappings>
        <DxTreeViewDataMapping Text="CategoryName" Children="Products"/>
        <DxTreeViewDataMapping Level="1" Text="ProductName"/>
    </DataMappings>
</DxTreeView>

@code {
    public IEnumerable<ProductCategory> Data => new List<ProductCategory>() {
        new ProductCategory() { CategoryName = "Bikes", Products = {
                new Product { ProductName = "Mountain Bikes" },
                new Product { ProductName = "Road Bikes" },
                new Product { ProductName = "Touring" }
            }
        },
        new ProductCategory() { CategoryName = "Components", Products = {
                new Product { ProductName = "Handlebars" },
                new Product { ProductName = "Bottom Brackets" },
                new Product { ProductName = "Brakes" },
                new Product { ProductName = "Chains" }
            }
        },
        new ProductCategory() { CategoryName = "Clothing", Products = {
                new Product { ProductName = "Bib-Shorts" },
                new Product { ProductName = "Caps" },
                new Product { ProductName = "Gloves" }
            }
        }
    };

    public class ProductCategory {
        public string CategoryName { get; set; }
        public List<Product> Products { get; } = new List<Product>();
    }

    public class Product {
        public string ProductName { get; set; }
    }
}
See Also