Adding a custom sorter to a column on a dbdg
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.
SIGN IN To post a reply.
3 Replies
AD
Administrator
Syncfusion Team
August 23, 2004 01:24 PM UTC
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
NA
Navid
May 5, 2008 05:30 AM UTC
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
>
>
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
>
>
JA
Janagan
Syncfusion Team
May 8, 2008 02:32 PM UTC
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:
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.
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.
SIGN IN To post a reply.
- 3 Replies
- 4 Participants
-
RH R. Hill
- Aug 23, 2004 11:47 AM UTC
- May 8, 2008 02:32 PM UTC