Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4111

How to scroll a MudBlazor DataGrid to bottom when page loads?

$
0
0

I have a MudBlazor DataGrid and need to scroll it from the bottom not from the top. This means that on page load it needs to have the scrollbar at the bottom.

I have tried some javascript interop but beacuse the muddatagrid outer div itself isn't the one scrolling I don't know what element to use JS interop on.

https://mudblazor.com/api/datagrid#pages

<MudDataGrid id="workoutPickerGrid" Dense=true T="Workout" Items="@data.Workouts.MyWorkouts" Breakpoint="Breakpoint.None" Filterable="true" Virtualize="true" HeaderClass="d-none" Height="100%" Style="height:100%;" ShowColumnOptions="false"><ChildRowContent><div class="d-flex justify-space-between align-center" @onclick=@(()=>navManager.NavigateTo($"/Workouts/View/{context.Item.ID}"))><MudText Typo="Typo.subtitle2">@context.Item.Name</MudText><MudText Typo="Typo.body2">@context.Item.StartedAt.GetTimeSinceString()</MudText></div><MudText Typo="Typo.body2">@context.Item.StartedAt.ToLongDateString()</MudText></ChildRowContent></MudDataGrid><script>    window.onload = function () {        var objDiv = document.getElementById("workoutPickerGrid");        objDiv.scrollTop = objDiv.scrollHeight;    }</script>

Viewing all articles
Browse latest Browse all 4111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>