Hi Christian,
Thanks for contacting Syncfusion support.
By default, Grid will sort based on all the records. So it is not
possible to avoid some records from sorting. However, you can use your own sorting
logic for columns using the “Sort Comparer” feature. Please refer to the below documentation
for more information.
|
@Component({
selector: 'app-root',
template: `<ejs-grid [dataSource]='data' [allowSorting]='true' height='315px'>
<e-columns>
<e-column field='CustomerID' [sortComparer]='sortComparer' headerText='Customer ID' width=150></e-column>
. . .
</e-columns>
</ejs-grid>`
})
export class AppComponent implements OnInit {
// The custom function where you can use your custom logic and return 0, 1 or -1
public sortComparer = (reference: string, comparer: string, referenceRecord: object, comparerRecord: object) => {
if (reference < comparer) {
return -1;
}
if (reference > comparer) {
return 1;
}
return 0;
}
}
|
https://ej2.syncfusion.com/angular/documentation/grid/sorting/#sort-comparer
Regards,
Pavithra S
If this post is helpful, please consider Accepting it as the
solution so that other members can locate it more quickly.