Skip to content

Commit 4845060

Browse files
author
KB Bot
committed
Added new kb article listview-hide-horizontal-scrollbar
1 parent 234e9ce commit 4845060

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: Hiding the Horizontal Scrollbar in ListView for Blazor
3+
description: This article describes how to hide the horizontal scrollbar in TelerikListView for Blazor by using custom CSS.
4+
type: how-to
5+
page_title: How to Hide Horizontal Scrollbar in TelerikListView for Blazor
6+
slug: listview-kb-hide-horizontal-scrollbar
7+
tags: scrollbar, listview, blazor
8+
res_type: kb
9+
ticketid: 1673222
10+
---
11+
12+
## Environment
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>ListView for Blazor</td>
19+
</tr>
20+
</tbody>
21+
</table>
22+
23+
## Description
24+
25+
In certain scenarios, it may be necessary to hide the horizontal scrollbar of the ListView component to improve the UI experience, especially when the ListView content is fully visible and does not require scrolling.
26+
27+
This knowledge base article also answers the following questions:
28+
29+
- How can I remove the horizontal scrollbar from a ListView component?
30+
- What CSS can hide the horizontal overflow in TelerikListView for Blazor?
31+
- Is there a way to ensure elements within ListView do not cause a horizontal scrollbar?
32+
33+
## Solution
34+
35+
To hide the horizontal scrollbar in a TelerikListView, apply custom CSS to set the overflow property of the ListView content wrapper to hidden. This approach ensures that the horizontal scrollbar is hidden, regardless of the content width. Implement the CSS rule as shown below:
36+
37+
> To maintain full visibility of the ListView elements without needing a scrollbar, ensure that the elements' width within the ListView does not exceed the ListView's width. You might need to adjust the width of the ListView or its elements accordingly:
38+
39+
````RAZOR
40+
<TelerikListView Data="@ListViewData"
41+
Width="700px"
42+
Pageable="true"
43+
PageSize="5"
44+
Class="my-listview">
45+
<HeaderTemplate>
46+
<h2>Employee List</h2>
47+
</HeaderTemplate>
48+
<Template>
49+
<div class="k-card k-card-horizontal" style="width:750px">
50+
<h4>@context.Name</h4>
51+
</div>
52+
</Template>
53+
</TelerikListView>
54+
55+
<style>
56+
.my-listview .k-listview-content {
57+
overflow-x: hidden;
58+
}
59+
</style>
60+
61+
@code {
62+
private List<SampleData> ListViewData { get; set; } = Enumerable.Range(1, 25).Select(x => new SampleData
63+
{
64+
Id = x,
65+
Name = $"Name {x}",
66+
Team = $"Team {x % 3}"
67+
}).ToList();
68+
69+
public class SampleData
70+
{
71+
public int Id { get; set; }
72+
public string Name { get; set; }
73+
public string Team { get; set; }
74+
}
75+
}
76+
````
77+
78+
## See Also
79+
80+
- [ListView Overview]({%slug listview-overview%})

0 commit comments

Comments
 (0)