DxDataMappingBase<TModel>.Level Property
Specifies the item level for which data mappings are applied.
Namespace: DevExpress.Blazor.Base
Assembly: DevExpress.Blazor.v21.1.dll
NuGet Package: DevExpress.Blazor
Declaration
[Parameter]
public int Level { get; set; }
Property Value
Type | Description |
---|---|
Int32 | 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 code below specifies different data mappings for different TreeView levels.
<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