Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo for Angular default grid sort

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>
like image 858
Zadok Avatar asked Mar 09 '23 23:03

Zadok


1 Answers

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.

like image 171
J. Farias Avatar answered Mar 11 '23 13:03

J. Farias