Skip to content

Commit 8e902fa

Browse files
Add documentation for the Grid Column Menu (#132)
* chore(grid): initial commit for the Column menu * chore(grid): added features section to the Column menu * chore(grid): updates on menu article * chore(grid): updates on column menu article * chore(grid): updates on column menu * chore(grid): updates on column menu * chore(grid): improvements on the column menu article * chore(grid): column menu article improvements * chore(grid): fix image file name * chore(grid): add paragraph for the column menu in the grid overview article * chore(grid): improvements to the column menu article * chore(grid): column menu article improvements based on feedback * chore(grid): add headers for the features of the column menu * docs(grid): fixes for inaccuracies and various issues in the oclumn menu docs * chore(grid): column chooser and example improvements * chore(grid): return sentnce I had deleter errorneously Co-authored-by: Marin Bratanov <[email protected]>
1 parent d225226 commit 8e902fa

File tree

6 files changed

+180
-0
lines changed

6 files changed

+180
-0
lines changed

components/grid/columns/bound.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ You can use the following properties on the bound columns:
9797

9898
* `Visible` - (defaults to `null`) - if this parameter is set to `false` it [hides]({%slug grid-columns-visible%}) the column from the Grid. Accepts both `bool` and `bool?` types, and `null` is treated like `true`.
9999

100+
* `ShowColumnMenu` - (defaults to `true`) - if set to false, disables the [column menu]({%slug grid-column-menu%}) for that particular column.
101+
102+
* `Lockable` - (defaults to `true`) - determines whether the user can [pin the column]({%slug grid-columns-frozen%}) through the [column menu]({%slug grid-column-menu%}).
103+
104+
* `VisibleInColumnChooser` - (defaults to `true`) - if set to false, removes the column from the Column chooser of the [column menu]({%slug grid-column-menu%}).
105+
100106
* `Template` - this property can also be used as an inner tag and it lets you define the [column display content]({%slug components/grid/features/templates%}#column-template). It can also point to a component name.
101107

102108
* `Context` - the standard Blazor context variable name for use inside the inline template.
Loading
Loading
Loading

components/grid/columns/menu.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
---
2+
title: Column Menu
3+
page_title: Grid - Column Menu
4+
description: Use the Column Menu for the Grid
5+
slug: grid-column-menu
6+
tags: telerik,blazor,grid,column,columns,menu
7+
published: True
8+
position: 20
9+
---
10+
11+
# Column Menu
12+
13+
The Grid allows you to setup a menu for it's columns. It enables you to perform high-level customization like [sorting]({%slug components/grid/features/sorting%}), [filtering]({%slug components/grid/filtering%}), [showing or hiding]({%slug grid-columns-visible%}) columns and [freezing or unfreezing]({%slug grid-columns-frozen%}) them.
14+
15+
>caption Telerik Column Menu for the Grid
16+
17+
![column menu basic example screenshot](images/column-menu-basic-example.png)
18+
19+
In this article:
20+
* [Basics](#basics)
21+
* [Features](#features)
22+
* [Sorting](#sorting)
23+
* [Filtering](#filtering)
24+
* [Frozen Columns](#frozen-columns)
25+
* [Column Chooser](#column-chooser)
26+
* [Notes](#notes)
27+
28+
## Basics
29+
30+
To enable the column menu set the `ShowColumnMenu` parameter of the `<TelerikGrid>` tag to `true`. This will enable the menu for each column of the Grid.
31+
32+
To disable the Column Menu for a specific column in the Grid set the `ShowColumnMenu` parameter of the column to `false`.
33+
34+
You can see the what the column menu can do and how to control its settings in the [Features](#features) section. By default, all of them are enabled.
35+
36+
>caption Enable the column menu for all Grid columns. Results in the screnshot above.
37+
38+
````CSHTML
39+
@* Set the ShowColumnMenu parameter to true *@
40+
41+
<TelerikGrid Data="@MyData"
42+
Pageable="true"
43+
PageSize="5"
44+
FilterMode="@GridFilterMode.FilterMenu"
45+
Sortable="true"
46+
ShowColumnMenu="true">
47+
<GridColumns>
48+
<GridColumn Field="@(nameof(SampleData.Id))" Width="80px" />
49+
<GridColumn Field="@(nameof(SampleData.Name))" Title="Employee Name" Groupable="false" />
50+
<GridColumn Field="@(nameof(SampleData.Team))" Title="Team" />
51+
<GridColumn Field="@(nameof(SampleData.HireDate))" Title="Hire Date" />
52+
</GridColumns>
53+
</TelerikGrid>
54+
55+
@code {
56+
public IEnumerable<SampleData> MyData = Enumerable.Range(1, 30).Select(x => new SampleData
57+
{
58+
Id = x,
59+
Name = "name " + x,
60+
Team = "team " + x % 5,
61+
HireDate = DateTime.Now.AddDays(-x).Date
62+
});
63+
64+
public class SampleData
65+
{
66+
public int Id { get; set; }
67+
public string Name { get; set; }
68+
public string Team { get; set; }
69+
public DateTime HireDate { get; set; }
70+
}
71+
}
72+
````
73+
74+
## Features
75+
76+
To control the common features of the `Column Menu` use the `<GridColumnMenuSettings>`, nested inside the `<GridSettings>`:
77+
78+
* [Sorting](#sorting)
79+
* [Filtering](#filtering)
80+
* [Frozen Columns](#frozen-columns)
81+
* [Column Chooser](#column-chooser)
82+
83+
### Sorting
84+
85+
To remove the sorting option from the Column Menu set the `Sortable` parameter of the `GridColumnMenuSettings` tag to `false`.
86+
87+
88+
### Filtering
89+
90+
To control whether filtering is possible from the Column Menu set the `FilterMode` parameter of the `GridColumnMenuSettings` tag to a member of the `ColumnMenuFilterMode` enum:
91+
92+
* `None` - disables the filtering from the Column Menu.
93+
* `FilterMenu` - enables a filter menu to apply filtering.
94+
95+
96+
### Frozen Columns
97+
98+
To disable locking and unlocking of a column from the Column Menu, set the `Lockable` parameter of the column to `false`.
99+
100+
101+
### Column Chooser
102+
103+
The Column Chooser in the Column Menu and allows you to toggle the visiblity of Grid columns from the Column Menu. By the default all columns are visible under the `Columns` section of the Column Menu (click the Columns item to expand it).
104+
105+
![column chooser screenshot](images/column-menu-chooser-in-action.gif)
106+
107+
To disable the column chooser, set the `ShowColumnChooser` paramter of the `<GridColumnMenuSettings>` to `false`.
108+
109+
To hide a column from the Column Chooser set the `VisibleInColumnChooser` property of the column to `false`.
110+
111+
### Example of Column Menu Features Settings
112+
113+
>caption Use the GridColumnMenuSettings tag to control the common features of the Column Menu, use column parameters to affect its relationship with the column menu
114+
115+
````CSHTML
116+
@* Disable filtering and locking columns, hide a column from the chooser (Team), disable the menu for a column (Name). *@
117+
118+
<TelerikGrid Data="@MyData"
119+
Pageable="true"
120+
PageSize="5"
121+
FilterMode="@GridFilterMode.FilterMenu"
122+
Sortable="true"
123+
ShowColumnMenu="true">
124+
<GridSettings>
125+
<GridColumnMenuSettings Lockable="false"
126+
FilterMode="@ColumnMenuFilterMode.None">
127+
</GridColumnMenuSettings>
128+
</GridSettings>
129+
<GridColumns>
130+
<GridColumn Field="@(nameof(SampleData.Id))" Width="80px" />
131+
<GridColumn Field="@(nameof(SampleData.Name))" Title="Employee Name" ShowColumnMenu="false" />
132+
<GridColumn Field="@(nameof(SampleData.Team))" Title="Team" VisibleInColumnChooser="false" />
133+
<GridColumn Field="@(nameof(SampleData.HireDate))" Title="Hire Date" />
134+
</GridColumns>
135+
</TelerikGrid>
136+
137+
@code {
138+
public IEnumerable<SampleData> MyData = Enumerable.Range(1, 30).Select(x => new SampleData
139+
{
140+
Id = x,
141+
Name = "name " + x,
142+
Team = "team " + x % 5,
143+
HireDate = DateTime.Now.AddDays(-x).Date
144+
});
145+
146+
public class SampleData
147+
{
148+
public int Id { get; set; }
149+
public string Name { get; set; }
150+
public string Team { get; set; }
151+
public DateTime HireDate { get; set; }
152+
}
153+
}
154+
````
155+
156+
>caption Column menu with filtering, locking and sorting, but without a column chooser
157+
158+
![column menu common settings example](images/column-menu-settings-example.gif)
159+
160+
## Notes
161+
162+
* Applying settings to a Grid column like `Filterable="false"`, `Sortable="false"`, `Lockable="false"` will take precendense over the common settings applied in the `<GridColumnMenuSettings>` and disable the above-mentioned functionalities for the corresponding column.
163+
164+
* An exception will be thrown if the `FilterMode` of the Grid is set to `FilterRow` and a column menu is used - the filter descriptors of the two features are not compatible.
165+
166+
* If the Grid has a [frozen]({%slug grid-columns-frozen%}) column (`Locked="true"`), that column cannot be unfrozen from the column menu.
167+
168+
## See Also
169+
170+
* [Live Demo: Visible Columns](https://demos.telerik.com/blazor-ui/grid/columns)

components/grid/overview.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ The grid offers single or multiple selection modes. You can read more about this
173173

174174
You can define user actions in a [dedicated toolbar]({%slug components/grid/features/toolbar%}). For the moment, they are mostly custom actions, but in future versions you will be able to add features like exporting there.
175175

176+
## Column Menu
177+
178+
The Grid allows you to setup a menu for it's columns. It enables you to perform high-level customization like [sorting]({%slug components/grid/features/sorting%}), [filtering]({%slug components/grid/filtering%}), [showing or hiding]({%slug grid-columns-visible%}) columns and [freezing or unfreezing]({%slug grid-columns-frozen%}) them. You can read more about this feature in the [column menu]({%slug grid-column-menu%}) article.
179+
176180
## Scrolling
177181

178182
The grid offers two modes of scrolling through its `ScrollMode` parameter that takes a member of the `Telerik.Blazor.GridScrollMode` enum:

0 commit comments

Comments
 (0)