Professional UI Solutions
Site Map   /  Register


Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Elegant Grid Tech Support » How to use a custom sorting method for a specific column only Collapse All
Subject Author Date
Francois Bronsard Oct 11, 2009 - 7:16 PM


I would like to use a custom sorting algorithm for the data in some columns but for the other columns I want to rely on the default sorting algorithm.  How can I do that? 

Using the "CompareRows" property I can attach a custom comparison operator but then I can’t find how to revert to the default comparison method if the current sort rule doesn’t include the columns for which I want to use my custom comparison.

Thanks in advance,


Francois Bronsard Oct 16, 2009 - 8:32 AM

Let me give a more detailed example then.

Suppose I have a grid, call it grid1, with 3 colums: Name, Phone, Address. If I sort the grid using the address column, I can to use a custom comparison, say conmpare_addresses, (for example, to handle zip code in a special way), but for the other columns, I want to use the default comparison operation. How do I do that? I can see how to invoke my comparison operator:

grid1.CompareRows += new Elegant.Grid.CompareObjectsEventHandler(my_CompareRows);

public void my_CompareRows(object sender, Elegant.Grid.CompareObjectsEventArgs e) {
System.Data.DataRowView X1 = (System.Data.DataRowView)e.X;
System.Data.DataRowView Y1 = (System.Data.DataRowView)e.Y;

if (grid1.SortRules[0].Column.DataPropertyName == "address") {
e.result = compare_addresses(X1.Row["address"], Y1.Row["address"]);
else { // Invoke the default comparison operation
???? <<<<<<<< How to do this?

Thanks in advance,

Technical Support Oct 16, 2009 - 7:58 AM

Could you provide more details on the problem or even send us a sample project so we can change the code to make the sample work as it should?