Skip to content

Commit

Permalink
Merge pull request #1249 from IgniteUI/ganastasov/tree-grid-sorting-t…
Browse files Browse the repository at this point in the history
…opic

Add tree grid sorting topic
  • Loading branch information
kacheshmarova authored Jun 7, 2024
2 parents 20822fc + ecbfb25 commit 2ab2f95
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 10 deletions.
153 changes: 145 additions & 8 deletions doc/en/components/grids/_shared/sorting.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ import { SortingDirection } from 'igniteui-webcomponents-grids';
import { SortingDirection } from "igniteui-react-grids";
```

<!-- ComponentStart: Grid, TreeGrid -->
<!-- ComponentStart: Grid -->
<!-- Angular -->
```typescript

Expand All @@ -92,7 +92,6 @@ this.grid.sort([
```
<!-- end: Angular -->


<!-- WebComponents -->
```typescript

Expand Down Expand Up @@ -125,7 +124,6 @@ this.grid.sort([
}
```


```tsx
// Perform a case insensitive ascending sort on the ProductName column.
gridRef.current.sort([{ fieldName: 'ProductName', dir: SortingDirection.Asc, ignoreCase: true }]);
Expand All @@ -136,7 +134,66 @@ gridRef.current.sort([
{ fieldName: 'Price', dir: SortingDirection.Desc }
]);
```
<!-- ComponentEnd: Grid, TreeGrid -->
<!-- ComponentEnd: Grid -->

<!-- ComponentStart: TreeGrid -->
<!-- Angular -->
```typescript

// Perform a case insensitive ascending sort on the Category column.
this.treeGrid.sort({ fieldName: 'Category', dir: SortingDirection.Asc, ignoreCase: true });

// Perform sorting on both the Category and Price columns.
this.treeGrid.sort([
{ fieldName: 'Category', dir: SortingDirection.Asc, ignoreCase: true },
{ fieldName: 'Price', dir: SortingDirection.Desc }
]);
```
<!-- end: Angular -->

<!-- WebComponents -->
```typescript

// Perform a case insensitive ascending sort on the Category column.
this.treeGrid.sort([{ fieldName: 'Category', dir: SortingDirection.Asc, ignoreCase: true }]);

// Perform sorting on both the Category and Price columns.
this.treeGrid.sort([
{ fieldName: 'Category', dir: SortingDirection.Asc, ignoreCase: true },
{ fieldName: 'Price', dir: SortingDirection.Desc }
]);
```
<!-- end: WebComponents -->

```razor
@code {
this.grtreeGridid.SortAsync(new IgbSortingExpression[]
{
new IgbSortingExpression
{
FieldName = "Category",
Dir = SortingDirection.Asc
},
new IgbSortingExpression
{
FieldName = "Price",
Dir = SortingDirection.Desc
}
});
}
```

```tsx
// Perform a case insensitive ascending sort on the Category column.
treeGridRef.current.sort([{ fieldName: 'Category', dir: SortingDirection.Asc, ignoreCase: true }]);

// Perform sorting on both the Category and Price columns.
treeGridRef.current.sort([
{ fieldName: 'Category', dir: SortingDirection.Asc, ignoreCase: true },
{ fieldName: 'Price', dir: SortingDirection.Desc }
]);
```
<!-- ComponentEnd: TreeGrid -->

<!-- ComponentStart: HierarchicalGrid -->
<!-- Angular -->
Expand Down Expand Up @@ -203,7 +260,7 @@ hierarchicalGridRef.current.sort([
As with the filtering behavior, you can clear the sorting state by using the `ClearSort` method:

<!-- ComponentStart: Grid, TreeGrid -->
<!-- ComponentStart: Grid -->
<!-- Angular, WebComponents -->
```typescript
// Removes the sorting state from the ProductName column
Expand Down Expand Up @@ -231,7 +288,37 @@ gridRef.current.clearSort();
this.grid.ClearSortAsync("");
}
```
<!-- ComponentEnd: Grid, TreeGrid -->
<!-- ComponentEnd: Grid -->

<!-- ComponentStart: TreeGrid -->
<!-- Angular, WebComponents -->
```typescript
// Removes the sorting state from the Category column
this.treeGrid.clearSort('Category');

// Removes the sorting state from every column in the {ComponentTitle}
this.treeGrid.clearSort();
```
<!-- end: Angular, WebComponents -->

```tsx
// Removes the sorting state from the Category column
treeGridRef.current.clearSort('Category');

// Removes the sorting state from every column in the {ComponentTitle}
treeGridRef.current.clearSort();
```

```razor
@code {
@*Removes the sorting state from the Category column*@
this.treeGrid.ClearSortAsync("Category");
@*Removes the sorting state from every column in the Grid*@
this.treeGrid.ClearSortAsync("");
}
```
<!-- ComponentEnd: TreeGrid -->

<!-- ComponentStart: HierarchicalGrid -->
<!-- Angular, WebComponents -->
Expand Down Expand Up @@ -273,7 +360,7 @@ hierarchicalGridRef.current.clearSort();

It is possible to set the initial sorting state of the `{ComponentName}` by passing an array of sorting expressions to the `SortingExpressions` property of the `{ComponentName}`.

<!-- ComponentStart: Grid, TreeGrid -->
<!-- ComponentStart: Grid -->
<!-- Angular -->
```typescript
public ngOnInit() {
Expand Down Expand Up @@ -321,7 +408,57 @@ useEffect(() => {
];
}, [])
```
<!-- ComponentEnd: Grid, TreeGrid -->
<!-- ComponentEnd: Grid -->

<!-- ComponentStart: TreeGrid -->
<!-- Angular -->
```typescript
public ngOnInit() {
this.treeGrid.sortingExpressions = [
{ fieldName: 'Category', dir: SortingDirection.Asc, ignoreCase: true },
{ fieldName: 'Price', dir: SortingDirection.Desc }
];
}
```
<!-- end: Angular -->

```razor
@code {
protected override void OnAfterRender(bool first)
{
if (first)
{
this.treeGrid.SortingExpressions = new IgbSortingExpression[]{
new IgbSortingExpression()
{
FieldName = "Category",
Dir = SortingDirection.Asc
}};
}
}
}
```

<!-- WebComponents -->
```typescript
public connectedCallback() {
this.treeGrid.sortingExpressions = [
{ fieldName: 'Category', dir: SortingDirection.Asc, ignoreCase: true },
{ fieldName: 'Price', dir: SortingDirection.Desc }
];
}
```
<!-- end: WebComponents -->

```tsx
useEffect(() => {
treeGridRef.current.sortingExpressions = [
{ fieldName: 'Category', dir: SortingDirection.Asc, ignoreCase: true },
{ fieldName: 'Price', dir: SortingDirection.Desc }
];
}, [])
```
<!-- ComponentEnd: TreeGrid -->

<!-- ComponentStart: HierarchicalGrid -->
<!-- Angular -->
Expand Down
4 changes: 2 additions & 2 deletions docfx/en/components/toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -808,10 +808,10 @@
"status": ""
},
{
"exclude": ["Angular", "React"],
"exclude": ["Angular"],
"name": "Sorting",
"href": "grids/tree-grid/sorting.md",
"status": ""
"status": ["NEW_REACT"]
},
{
"exclude": ["Angular", "React", "WebComponents", "Blazor"],
Expand Down

0 comments on commit 2ab2f95

Please sign in to comment.