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.
Unfortunately, activation email could not send to your email. Please try again.

How to Show Sort icon

Thread ID:

Created:

Updated:

Platform:

Replies:

56659 Feb 19,2007 01:41 AM Feb 19,2007 10:34 AM Windows Forms 1
loading
Tags: GridControl
Vasanth
Asked On February 19, 2007 01:41 AM

Hi,

We are using Syncfusion grid for VS.NET 2003.
We have written codes to sort and display the records based on the header in which user clicks. We want to show sort icon (triangle) in the grid header once the user clicks on the header.

Eg : We have a grid with col A, Col B, Col C.

If the user clicks on Col A, the relavent (asc, dec) sort icon should be shown in the header with the colun name

Thanks
R.Vasanth

Administrator [Syncfusion]
Replied On February 19, 2007 10:34 AM

Hi Vasanth,

Sorting is directly supported in a GridDataBoundGrid based on the grids through the underlying datatable. For GridControl based grids, the GridControlSort ( \Syncfusion\Essential Studio\4.4.0.49\Windows\Grid.Windows\Samples\FeatureSamples\GridControlSort )browser sample will show you how to add header-click sorting to your grid. The header cell draws a sort icon to indicate that the column has been sorted in a particular direction.

There is an inbuilt class, the GridSortColumnHeaderCellModel which, by passing an instance through the CellModels.Add function creates a CellType.

this.gridControl1.CellModels.Add("ColumnHeaderCell", new GridSortColumnHeaderCellModel(this.gridControl1.Model));
this.gridControl1[0, col].CellType = "ColumnHeaderCell";

The direction of the sort icon can be controlled by passing the Ascending or Descending options of the ListSortDirection enumerator through the tag property of the grid.

ListSortDirection dir = ListSortDirection.Ascending;
this.gridControl1[0, col].Tag = dir;

Sorting is done by the Data.SortByColumn function. There are 5 overloads for this function. It also enables comparison through the custom comparer.

this.gridControl1.Data.SortByColumn(col, dir, new FormulaComparer());

A custom comparer class which, derives the IComparer is used to compare the formula values and not the formulas. The FormulaTag.Text property has the formula result and it is used to compare two cells.

Here is a sample.
GridControlSort.zip

Best regards,
Haneef

CONFIRMATION

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.

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.

;