Skip to content

Commit b324cc6

Browse files
docs(grid): column reorder
1 parent be49257 commit b324cc6

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

components/grid/columns/bound.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ They are added to the `GridColumns` tag and are of type `GridColumn`. You can us
1818
* `Title` - the text that is rendered in the column header.
1919
* `Editable` - you can set this property to `true` or `false` to allow or prevent [editing]({%slug components/grid/overview%}#editing) of this field. Defaults to `true`.
2020
* `Filterable` - you can set this to `false` so a [filterable]({%slug components/grid/filtering%}) grid will not let the user filter that particular column.
21+
* `Groupable` - whether the use can [group]({%slug components/grid/features/grouping%}) the grid by this column.
22+
* `Reorderable` - whether the user can [drag to reorder]({%slug components/grid/columns/reorder%}) this column.
2123
* `Width` - the width of the column. See the [Dimensions]({%slug common-features/dimensions%}) article. Keep in mind that these are columns in a `<table>`, so it is often a good practice to leave one column without explicit dimensions so it can accommodate the remaining width and changes to the container size.
2224
* `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.
2325
* `Context` - the standard Blazor context variable name for use inside the inline template.
2426
* `ref` - the standard Blazor reference name.
2527
* `EditorTemplate` - this property can also be used as an inner tag and it lets you define the [column edit content]({%slug components/grid/features/templates%}#edit-template). It can also point to a component name.
2628

27-
For an example of the column usage, see the [Grid Overview]({%slug components/grid/overview%}) article and the [examples repo](https://github.com/telerik/ui-for-blazor-examples/).
29+
For an example of the column usage, see the [Grid Overview]({%slug components/grid/overview%}), the rest of the documentation and our [live demos](https://demos.telerik.com/blazor-ui/grid/overview).
2830

2931
## See Also
3032

78.1 KB
Loading

components/grid/columns/reorder.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Reorder
3+
page_title: Grid for Blazor | Reorder Columns
4+
description: Drag to reorder columns in the Grid for Blazor
5+
slug: components/grid/columns/reorder
6+
tags: telerik,blazor,grid,column,reorder,drag
7+
published: True
8+
position: 0
9+
---
10+
11+
# Reorder Columns
12+
13+
The Grid lets the user reorder its columns by dragging their headers.
14+
15+
To enable the column reordering, set the `Reorderable` parameter of the grid to `true`.
16+
17+
To prevent the user from moving a certain column, set its own parameter `Reordarable="false"`. Note that the user can still re-arrange other columns around it.
18+
19+
>caption Enable column reordering in Telerik Grid
20+
21+
````CSHTML
22+
@* Drag a column header between other columns to change the columns positions. You cannot drag the command column. Note that actual CRUD operations and settings are not implemented here for brevity. *@
23+
24+
<TelerikGrid Data="@GridData"
25+
Reorderable="true"
26+
Pageable="true" PageSize="10" Sortable="true" Height="300px">
27+
<GridColumns>
28+
<GridColumn Field=@nameof(SampleData.Id) Title="Id" />
29+
<GridColumn Field=@nameof(SampleData.Name) Title="First Name" />
30+
<GridColumn Field=@nameof(SampleData.LastName) Title="Last Name" />
31+
<GridCommandColumn Width="100px" Reorderable="false">
32+
<GridCommandButton Command="Save" Icon="save" ShowInEdit="true">Update</GridCommandButton>
33+
<GridCommandButton Command="Edit" Icon="edit">Edit</GridCommandButton>
34+
<GridCommandButton Command="Delete" Icon="delete">Delete</GridCommandButton>
35+
<GridCommandButton Command="Cancel" Icon="cancel" ShowInEdit="true">Cancel</GridCommandButton>
36+
</GridCommandColumn>
37+
</GridColumns>
38+
</TelerikGrid>
39+
40+
@code {
41+
public List<SampleData> GridData { get; set; }
42+
43+
protected override void OnInitialized()
44+
{
45+
GridData = GetData();
46+
}
47+
48+
private List<SampleData> GetData()
49+
{
50+
return Enumerable.Range(1, 50).Select(x => new SampleData
51+
{
52+
Id = x,
53+
Name = $"name {x}",
54+
LastName = $"Surname {x}"
55+
}).ToList();
56+
}
57+
58+
public class SampleData
59+
{
60+
public int Id { get; set; }
61+
public string Name { get; set; }
62+
public string LastName { get; set; }
63+
}
64+
}
65+
````
66+
67+
68+
>caption How column reordering works in the Telerik grid
69+
70+
![](images/column-reorder-preview.gif)
71+
72+
## See Also
73+
74+
* [Live Demo: Column Reordering](https://demos.telerik.com/blazor-ui/grid/column-reordering)

0 commit comments

Comments
 (0)