Skip to content

Commit b310e2b

Browse files
kendo-botKB Botxristianstefanov
authored
Added new kb article listview-kb-display-items-horizontally (#2317)
* Added new kb article listview-kb-display-items-horizontally * docs(listview): apply suggestions --------- Co-authored-by: KB Bot <[email protected]> Co-authored-by: Hristian Stefanov <[email protected]>
1 parent a332cab commit b310e2b

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: Display ListView Items Horizontally in Blazor
3+
description: Learn how to arrange the items in a TelerikListView for Blazor horizontally using custom CSS styles.
4+
type: how-to
5+
page_title: How to Arrange Telerik Blazor ListView Items Horizontally
6+
slug: listview-kb-display-items-horizontally
7+
tags: listview, blazor, layout, css, styling
8+
res_type: kb
9+
ticketid: 1649286
10+
---
11+
12+
## Environment
13+
<table>
14+
<tbody>
15+
<tr>
16+
<td>Product</td>
17+
<td>ListView for Blazor</td>
18+
</tr>
19+
</tbody>
20+
</table>
21+
22+
## Description
23+
24+
I want to display the items in the TelerikListView component horizontally.
25+
26+
This KB article answers the following questions:
27+
- How to set the TelerikListView layout to horizontal?
28+
- Is it possible to display ListView items side by side in Blazor?
29+
30+
## Solution
31+
32+
To display the ListView items horizontally, apply the `display: inline-block;` CSS style to the `k-listview-item` HTML div element. This approach allows you to customize the appearance of each ListView item and arrange them side by side.
33+
34+
`````CSHTML
35+
<style>
36+
.horizontal-listview .k-listview-item {
37+
height: 150px;
38+
width: 150px;
39+
display: inline-block;
40+
margin: 10px;
41+
border: 1px solid black;
42+
border-radius: 10px;
43+
padding: 10px;
44+
}
45+
</style>
46+
47+
<TelerikListView Data="@ListViewData"
48+
Class="horizontal-listview"
49+
Pageable="true"
50+
PageSize="4"
51+
Width="700px">
52+
<HeaderTemplate>
53+
<h2>Employee List</h2>
54+
</HeaderTemplate>
55+
<Template>
56+
<h4>@context.Name</h4>
57+
<h5>@context.Team</h5>
58+
</Template>
59+
</TelerikListView>
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+
- [TelerikListView for Blazor - Overview](https://docs.telerik.com/blazor-ui/components/listview/overview)
80+
- [TelerikListView for Blazor - Templates](https://docs.telerik.com/blazor-ui/components/listview/templates)

0 commit comments

Comments
 (0)