Hi
The idea we have is to have a list of tileLayoutitems. The user starts with an empty TileLayout and starts a wizard, the wizard lets the user choose from a list which tilelayoutitems he or she wants to see. We save this information in our database. So then, we need code to populate the tilelayout with the choosen tilelayout items.
Qeustion is this possible to do and how?
Eric
public class myComponentlayout : TileLayoutItemState
{
public string HeaderText { get; set; } = "";
public string Class { get; set; } = "";
public RenderFragment renderFragment { get; set; }
}
Load my list of Widgets and build the RenderFraments into a new list:
case ENUMValues.Widget.W_F2COL:
{
one = new myComponentlayout();
one.renderFragment = (builder) =>
{
builder.OpenComponent(0, new WidgetFeatured2Col().GetType());
builder.AddAttribute(1, "IdWidgets", Widget.IdWidgets);
builder.CloseComponent();
};
}
break;
Build the TileLayout dynamically off the created list of RenderFragments:
<TelerikTileLayout Columns="6"
Width="100%"
RowHeight="150px"
Reorderable="true"
@ref="TileLayoutInstance">
<TileLayoutItems>
@foreach (var item in list)
{
<TileLayoutItem RowSpan="@item.RowSpan" ColSpan="@item.ColSpan" HeaderText="@item.HeaderText" Class="@item.Class">
<Content>
@item.renderFragment
</Content>
</TileLayoutItem>
}
</TileLayoutItems>
</TelerikTileLayout>
I use the MediaQuery and the GetState/SetState in OnAfterRenderAsync() to modify the row/col based on screen size.
Not sure how efficient it is but I have everything working except for changing the order on different screen sizes