Skip to content

Commit 273e922

Browse files
github-actions[bot]KB BotTsvetomir-Hrdimodi
authored
Merge new-kb-grid-remove-group-indent-e7be6242097049588624e2b10cc4f486-2908 into production (#2931)
* Added new kb article grid-remove-group-indent * chore: fix example and slugs * chore: polish kb article content based on pr suggestions * Update knowledge-base/grid-remove-group-indent.md --------- Co-authored-by: KB Bot <[email protected]> Co-authored-by: Tsvetomir Hristov <[email protected]> Co-authored-by: Dimo Dimov <[email protected]>
1 parent 42334a5 commit 273e922

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed
+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
title: Removing Group Indent in Grid for Blazor
3+
description: This article demonstrates how to remove the group indent in the Grid for Blazor by overriding the default theme styles.
4+
type: how-to
5+
page_title: How to Remove Group Indentation in Blazor Grid
6+
slug: grid-kb-remove-group-indent
7+
tags: grid, blazor, grouping, indentation
8+
res_type: kb
9+
ticketid: 1684110
10+
---
11+
12+
## Description
13+
14+
This knowledge base article answers the following questions:
15+
16+
- Is there a way to remove the group indent and adjust the spacing without compromising the Grid behavior?
17+
- How can I customize the grouping appearance in a Blazor Grid?
18+
- How to hide the group indent and group header icons in a Blazor Grid?
19+
- What is the best way to hide the expand/collapse icons of the groups headers in a Telerik Blazor Grid?
20+
21+
## Environment
22+
23+
<table>
24+
<tbody>
25+
<tr>
26+
<td>Product</td>
27+
<td>Grid for Blazor</td>
28+
</tr>
29+
</tbody>
30+
</table>
31+
32+
## Solution
33+
34+
To remove the group indent in the [Grid for Blazor](slug:grid-overview) and hide the expand/collapse icons of the groups, you will need to override the default theme styles. This solution involves applying custom CSS styles to the Grid component. Run the example below and group the Grid by some of the columns to see the removed group indentation:
35+
36+
````RAZOR
37+
<TelerikGrid Data=@GridData
38+
Groupable="true"
39+
Pageable="true"
40+
Height="400px"
41+
Class="custom-grouping">
42+
<GridColumns>
43+
<GridColumn Field=@nameof(Employee.Name) Groupable="false" />
44+
<GridColumn Field=@nameof(Employee.Team) Title="Team" />
45+
<GridColumn Field=@nameof(Employee.IsOnLeave) Title="On Vacation" />
46+
</GridColumns>
47+
</TelerikGrid>
48+
49+
<style>
50+
.custom-grouping.k-grid .k-group-col {
51+
width: 0;
52+
}
53+
54+
.custom-grouping.k-grid .k-grouping-row .k-icon {
55+
display: none;
56+
}
57+
</style>
58+
59+
@code {
60+
private List<Employee>? GridData { get; set; }
61+
62+
protected override void OnInitialized()
63+
{
64+
GridData = new List<Employee>();
65+
var rand = new Random();
66+
for (int i = 0; i < 15; i++)
67+
{
68+
GridData.Add(new Employee()
69+
{
70+
EmployeeId = i,
71+
Name = "Employee " + i.ToString(),
72+
Team = "Team " + i % 3,
73+
IsOnLeave = i % 2 == 0
74+
});
75+
}
76+
}
77+
78+
public class Employee
79+
{
80+
public int EmployeeId { get; set; }
81+
public string Name { get; set; } = string.Empty;
82+
public string Team { get; set; } = string.Empty;
83+
public bool IsOnLeave { get; set; }
84+
}
85+
}
86+
````
87+
88+
## See Also
89+
90+
- [Grid Overview](slug:grid-overview)
91+
- [Override Theme Styles](slug:themes-override)

0 commit comments

Comments
 (0)