Hi Mohamed,
Thanks for your interest in Syncfusion products.
We can achieve your requirement using the actionBegin event of the Grid. In actionBegin event, when the requestType is “sorting”, we can the corresponding columnName in the event arguments and thus can prevent the default sort action by settings the argument.cancel as true.
The APIs used in Angular 2 is like that JavaScript APIs only the syntax for the member definition differs. For example, in JavaScript allowFiltering is used to enable filtering to grid whereas in Angular 2, we define the properties within square brackets ie [allowFiltering]. Please refer to the below document for angular2 properties and events declarations syntax.
Please refer to the below code example.
<h2>Syncfusion Javascript Angular 2 Component</h2>
<ej-grid #grid [dataSource]="employeeData" [allowPaging]="true" [allowSorting]="true" (actionBegin)="onBegin($event)" >
. . . .
</ej-grid>
export class AppComponent {
onBegin(e:any){
if(e.requestType == "sorting"){
alert("Sorted Field Name: " +e.columnName);//display the column field name
alert("Sorted Column Header Text: "+this.Grid.widget.getHeaderTextByFieldName(e.columnName));//display the column header text
e.cancel = true;//prevent the default sort action
}
}
} |
We have prepared a sample for your reference, which can be downloaded from the below location.
Regards,
Ragavee U S.