We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I catch sort event

Thread ID:





127756 Dec 7,2016 03:19 AM UTC Dec 8,2016 07:21 AM UTC Angular 1
Tags: ejGrid
Mohamed Abozeid
Asked On December 7, 2016 03:19 AM UTC

I want to catch the column sorting event. after click the  column  header I want to catch the column title and stop default sorting action.

Ragavee U S [Syncfusion]
Replied On December 8, 2016 07:21 AM UTC

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)" > 
    . . . . 
export class AppComponent { 
    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. 

Ragavee U S. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon