public void Click()
{
var item = Data[Data.Count - 1];
// call the JS function to move the scroller position.
JSRuntime.InvokeAsync<string>("ListView", item);
}
Host.cshtml
<script>
function ListView(args) {
// move the scroller to correspoding element by using scrollintoview method.
document.querySelector('[data-uid="' + args.id + '"]').scrollIntoView();
}
</script> |
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
var item = Data[Data.Count - 1];
// call the JS function to move the scroller position.
JSRuntime.InvokeAsync<string>("ListView", item);
}
} |
<SfDialog Width="250px" IsModal="true" @bind-Visible="@IsVisible" ShowCloseIcon="true">
<DialogEvents Opened="open">
</DialogEvents>
<DialogTemplates>
<Content>
<SfListView ID="listview" DataSource="@Data" ShowCheckBox="true" @ref="@list" Height="200px">
<ListViewFieldSettings Id="Id" Text="Text" IsChecked="isChecked"></ListViewFieldSettings>
</SfListView>
</Content>
</DialogTemplates>
</SfDialog>
public void open(Object args)
{
var item = Data[Data.Count - 1];
// call the JS function to move the scroller position.
JSRuntime.InvokeAsync<string>("ListView", item);
} |
Hi ,
Are there provided support to move the scrollbar position now?
Or javascript call still only way ?
Thanks
Hi,
As mentioned earlier, we do not have a direct method to programmatically scroll to a specific item in the ListView component with virtualization support. The User Interface (UI) virtualization only loads the list items that are visible within the viewport and the DOM. Therefore, when using virtualization support, it is not possible to access or view items that are not currently loaded. This limitation exists in our component. Please refer to the link below for more information about the virtualization limitations in the ListView component.
https://blazor.syncfusion.com/documentation/listview/virtualization#limitations-for-virtualization
Note: If you are not utilizing virtualization support, you can achieve your desired result by using the scrollIntoView method and passing the corresponding list item ID(With the help of interop call).
Regards,
Leo Lavanya Dhanaraj