Kendo for Angular default grid sort
Asked Answered
B

1

5

Does anyone know how to set the default sort field in the Kendo for Angular grid?

<kendo-grid [data]="view | async"
          [pageSize]="gridState.take"
          [skip]="gridState.skip"
          [sort]="gridState.sort"
          [pageable]="{
            buttonCount: 3,
            info: true,
            type: 'numeric',
            pageSizes: true,
            previousNext: true
          }"
          [sortable]="true"
          (dataStateChange)="onStateChange($event)"
          (edit)="editHandler($event)" (cancel)="cancelHandler($event)"
          (save)="saveHandler($event)">
<kendo-grid-column field="Name" width="200" [editable]="false"></kendo-grid-column>
<kendo-grid-column field="Group" width="120" [editable]="false"></kendo-grid-column>
Bloomers answered 1/6, 2017 at 20:21 Comment(0)
G
9

Try setting the gridState.sort property to what you want for the default field.

gridState.sort = [{ 'field': 'createdDate', 'dir': 'desc' }];

You can set the property where you declare it.

Galling answered 21/6, 2017 at 14:52 Comment(1)
Perfect. Thanks for building up the knowledge base of the Kendo-Angular world J.Bloomers

© 2022 - 2024 — McMap. All rights reserved.