Back to Devexpress

DxDataMappingBase<TModel>.Level Property

blazor-devexpress-dot-blazor-dot-base-dot-dxdatamappingbase-1-6be66479.md

latest2.8 KB
Original Source

DxDataMappingBase<TModel>.Level Property

Specifies the item level for which data mappings are applied.

Namespace : DevExpress.Blazor.Base

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

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

Property Value

TypeDefaultDescription
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

DxDataMappingBase<TModel> Class

DxDataMappingBase<TModel> Members

DevExpress.Blazor.Base Namespace