Skip to content

Commit 363e183

Browse files
Grid multicolumn sort (#129)
* docs(grid): multi column sorting * docs(treelist): multi column sorting * chore(grid): remove multi column sort from TOC, it renders ugly * chore(grid): add multi column sorting image
1 parent edeca55 commit 363e183

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Loading

components/grid/sorting.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,58 @@ Click a column header to sort by its data
5050

5151
You can sort this grid on the different columns to see the results. The `Name` column is a string, and sorting is done according to the rules for strings, while the `ID` column sorts acording to rules for integers.
5252

53+
54+
### Multi Column Sorting
55+
56+
To allow sorting on more than one column at a time, set the `SortMode` parameter of the grid to `Telerik.Blazor.SortMode.Multiple`.
57+
58+
>caption Enable multi column sorting
59+
60+
````CSHTML
61+
@* Try sorting by Team, then by Name to see how the multiple sorts apply *@
62+
63+
<TelerikGrid Data=@GridData Sortable="true" SortMode="@SortMode.Multiple"
64+
Pageable="true" Height="400px">
65+
<GridColumns>
66+
<GridColumn Field=@nameof(Employee.Name) />
67+
<GridColumn Field=@nameof(Employee.Team) Title="Team" />
68+
<GridColumn Field=@nameof(Employee.IsOnLeave) Title="On Vacation" />
69+
</GridColumns>
70+
</TelerikGrid>
71+
72+
@code {
73+
public List<Employee> GridData { get; set; }
74+
75+
protected override void OnInitialized()
76+
{
77+
GridData = new List<Employee>();
78+
var rand = new Random();
79+
for (int i = 0; i < 15; i++)
80+
{
81+
GridData.Add(new Employee()
82+
{
83+
EmployeeId = i,
84+
Name = "Employee " + i.ToString(),
85+
Team = "Team " + i % 3,
86+
IsOnLeave = i % 2 == 0
87+
});
88+
}
89+
}
90+
91+
public class Employee
92+
{
93+
public int EmployeeId { get; set; }
94+
public string Name { get; set; }
95+
public string Team { get; set; }
96+
public bool IsOnLeave { get; set; }
97+
}
98+
}
99+
````
100+
101+
>caption Numbers in the column headers indicate the order by which the grid is sorted
102+
103+
![multiple column sorting in grid](images/grid-multi-column-sorting.png)
104+
53105
## Sort From Code
54106

55107
You can sort the grid from your own code through its [state]({%slug grid-state%}).

components/treelist/sorting.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ You can sort the treelist on the different columns and sorting is done according
2222

2323
Sorting keeps the expanded/collapsed state of items. For example, if filtering brings into view a child whose parent is collapsed, you will only see the collapsed parent.
2424

25+
You can let the user sort by more than one field by setting the `SortMode` parameter to `Telerik.Blazor.SortMode.Multiple`.
26+
2527
>caption Enable Sorting in Telerik TreeList
2628
2729
````CSHTML
@@ -96,6 +98,8 @@ Click a column header to sort by its data
9698
9799
![](images/basic-sorting.png)
98100

101+
102+
99103
## See Also
100104

101105
* [Live Demo: TreeList Sorting](https://demos.telerik.com/blazor-ui/treelist/sorting)

0 commit comments

Comments
 (0)