Hi Nagendra,
Thanks for contacting Syncfusion support.
Query: I want only ascending and descending sorting in grid.
Based on your requirement, you need to perform sorting action only with ascending and descending order. You can achieve your requirement by using following cod example in the actionBegin event of Grid.
|
[app.component.ts]
actionBegin(args) {
if (args.requestType === 'sorting' && isNullOrUndefined(args.direction)) {
args.cancel = true; // prevent the None sort action
let tarEle = null;
if (args.target.classList.contains('e-headercell')) {
tarEle = args.target.querySelector('.e-headercelldiv');
} else {
tarEle = parentsUntil(args.target, 'e-headercell').querySelector('.e-headercelldiv');
}
let thEle = this.grid.getColumnHeaderByUid(tarEle.getAttribute('e-mappinguid'));
this.fieldName = this.grid.getColumnByIndex(parseInt(thEle.getAttribute('aria-colindex'))).field;
let isMultiSort = this.grid.allowMultiSorting && this.grid.sortSettings.columns.length ? true : false;
this.grid.sortColumn(this.fieldName, 'Ascending', isMultiSort); // sort the column with ascending
}
}
|
We have prepared a sample for your reference. You can get it from the below link,
Please get back to us if you need further assistance with this.
Regards,
Rajapandiyan S