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.

Adding a custom sorter to a column on a dbdg

Thread ID:

Created:

Updated:

Platform:

Replies:

18035 Aug 23,2004 07:47 AM May 8,2008 10:32 AM Windows Forms 3
loading
Tags: GridControl
R. Hill
Asked On August 23, 2004 07:47 AM

Hi, I want to customize the sort behavior of an ID column as follows: CMJGB10Y CMJGB2Y I tried creating a custom object with the IComparable interface, but the dbdg does not appear to call this compare to. I read the GridControlSort project, but that method doesnt seem to map onto dbdg easily. How can I make the dbdg sort this column with my custom sorting behaviour? There should be an easy way such as overriding IComparable.

Administrator [Syncfusion]
Replied On August 23, 2004 09:24 AM

Attached is a sample that sorts a column based on string.length by having a custom object implement IComparable. If your custom object is not editable in the grid, then this would be all you would need I think. But if your custom object needed to be editable within the grid''s UI, then you would need more work, maybe deriving a cell control that understood your object and how to edit it. GDBGDataView_6877.zip

Navid
Replied On May 5, 2008 01:30 AM

Could you please make a sample for ASP.NET?
Thank you!

Navid

>Attached is a sample that sorts a column based on string.length by having a custom object implement IComparable. If your custom object is not editable in the grid, then this would be all you would need I think. But if your custom object needed to be editable within the grid's UI, then you would need more work, maybe deriving a cell control that understood your object and how to edit it.
>
>GDBGDataView_6877.zip
>
>


Janagan [Syncfusion]
Replied On May 8, 2008 10:32 AM

Hi Navid,

Thank you for evaluating Syncfusion Products.

You can sort the columns using Icomparable interface based on the length of the string in the cell of the grid by the following code:




public class MyObject : IComparable
{
public MyObject(string s)
{
this.s = s;
}
public override string ToString()
{
return s;
}

string s;
public string Val
{
get { return s; }
set { s = value; }
}

public int CompareTo(object obj)
{

return this.ToString().Length - obj.ToString().Length;
}



Please refer the sample in the link below which illustrates the above:

http://websamples.syncfusion.com/samples/Grid.Web/6.2.0.40/Grid_ASP_sortinggrid/main.htm



Please try running this and let me know if this helps.

Thanks,
Janagan.








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.

;