Hey i'd like to make a dashboard using the TileLayout Component in .Net Core. But I want to add different kinds of widgets from a List in the model. Each Container shall be added using one of many templates. I want the templates to render a partial view and have the views get their own data using the Id of the widget. But I don't know how to give the view the id of the container that is currently being created.
This is the code I have so far:
<div class="container-fluid">
@(Html.Kendo().TileLayout()
.Name("dashboardLayout")
.HtmlAttributes(new {style = "overflow:hidden;"})
.Width(String.Format("{0}", (@customModel.ColumWidth * @customModel.ColumCount)))
.Columns(@customModel.ColumCount)
.RowsHeight(String.Format("{0}px", @customModel.RowHeight))
.ColumnsWidth(String.Format("{0}px", @customModel.ColumWidth))
.Gap(g => g.Columns(@customModel.VerticalGap).Rows(@customModel.HorizontalGap))
.Reorderable(true)
.Resizable(true)
.Containers(c => {
foreach(DashboardWidgetConfigurationModel widget in @customModel.Widgets) {
c.Add().Header(h=>h.Text(@customModel.ColumWidth.ToString())).BodyTemplateId("single-value-circle-widget").ColSpan(5).RowSpan(2);
}
})
.Events(e => e.Resize("onTileResize"))
)
</div>
<script id="single-value-circle-widget" type="text/x-kendo-template">
@await Html.PartialAsync("../Dashboard/SingleValueCircleWidget", #= widget #) //the widget model contains the id
</script>
Long story short:
I want to access the current DashboardWidgetConfigurationModel from the foreach loop in the template.