Data Binding in Breadcrumb
17 Feb 20221 minute to read
Items based on current Url
The Breadcrumb items can be generated from the current URL of the page, if the url
property was not provided or when the user does not specify the breadcrumb items using the BreadcrumbItemDirective tag. The following example shows the breadcrumb items that are generated based on the current URL.
@Html.EJS().Breadcrumb("default")..EnableNavigation(false).Render()
Output be like the below.
This output screenshot shows the Bind to Location sample.
This sample is hosted in different location, so the breadcrumb is rendered with different location instead of the actual location.
Static URL
The Breadcrumb items can be generated by providing the url
property in the component, if the user does not specify the breadcrumb items using the BreadcrumbItemDirective tag. The following example shows the breadcrumb items generated from the provided url in the component.
@Html.EJS().Breadcrumb("url").EnableNavigation(false).Url("https://ej2.syncfusion.com/aspnetmvc/Breadcrumb/DefaultFunctionalities").Render()
public ActionResult Index()
{
return View();
}
Output be like the below.
Customize text when generated items using Url
The Breadcrumb items text can be customized by using the beforeItemRender
event. In the following example, All Components
text was customized as Components
.
@Html.EJS().Breadcrumb("url").EnableNavigation(false).BeforeItemRender("beforeItemRender").Url("https://ej2.syncfusion.com/aspnetmvc/Breadcrumb/BindToLocation").Render()
<script>
function beforeItemRender(args) {
if (args.item.text === 'BindToLocation') {
args.item.text = 'location';
}
}
</script>
public ActionResult Index()
{
return View();
}
Output be like the below.