Hi Telerik team,
I’ve run into this issue with the TelerikTileLayout component where toggling Resizable or Reorderable dynamically doesn’t fully enable the functionality. The current workaround—hiding and showing the component to force reinstantiation—works but is inefficient, especially with complex tile layouts, as it recreates everything from scratch.
After digging into TelerikTileLayout component, I found the problem: the _resizableChanged and _reorderableChanged flags can reset prematurely if SetParametersAsync runs multiple times before OnAfterRenderAsync, skipping the "setOptions" JavaScript call.
Here’s a suggested fix for the component:
In SetParametersAsync:
_resizableChanged |= parameters.HasParameterChanged("Resizable", Resizable);
_reorderableChanged |= parameters.HasParameterChanged("Reorderable", Reorderable);
In OnAfterRenderAsync:
if (_resizableChanged || _reorderableChanged)
{
await InvokeVoidAsync("setOptions", base.DataId, GetTileLayoutWidgetOptions());
_resizableChanged = _reorderableChanged = false;
}
This avoids reinstantiation, boosts performance, and makes dynamic toggling reliable. Happy to elaborate if needed—let me know!
Here is a workaround that hides the component so it can re-initialize from scratch with the new parameter values
<TelerikButton OnClick="@ToggleResizing">Toggle Resizable</TelerikButton>
<TelerikButton OnClick="@ToggleReorder">Toggle Reordable</TelerikButton>
@if (isVisible)
{
<TelerikTileLayout Columns="3"
Resizable="@Resizable"
Reorderable="@Reordable"
RowHeight="150px">
<TileLayoutItems>
<TileLayoutItem HeaderText="Panel 1">
<Content>Regular sized first panel.</Content>
</TileLayoutItem>
<TileLayoutItem HeaderText="Panel 2">
<Content>You can put components in the tiles too.</Content>
</TileLayoutItem>
<TileLayoutItem HeaderText="Panel 3" RowSpan="3">
<Content>This tile is three rows tall.</Content>
</TileLayoutItem>
<TileLayoutItem HeaderText="Panel 4" RowSpan="2" ColSpan="2">
<Content>This tile is two rows tall and two columns wide</Content>
</TileLayoutItem>
</TileLayoutItems>
</TelerikTileLayout>
}
@code{
bool Resizable { get; set; }
bool Reordable { get; set; }
bool isVisible { get; set; } = true;
async Task ToggleResizing()
{
isVisible = false;
await Task.Delay(30);
Resizable = !Resizable;
isVisible = true;
}
async Task ToggleReorder()
{
isVisible = false;
await Task.Delay(30);
Reordable = !Reordable;
isVisible = true;
}
}
Regards,
Marin Bratanov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.