hi ,
i have ultraGrid ,the grid dataSource binding from list of object like the follwing :
List<Stock> list = new List<Stock> ;
ultraGrid1.DataSource = list ;
Calss Stock {
private string Price;
private string Volume}
i did the follwing things in InitializeLayout:
e.Layout.Bands[0].Columns[
"Price"].Style = ColumnStyle.Double;
e.Layout.Bands[0].Columns["Volume"].Style = ColumnStyle.Double;
--------------------my Quistion is -------------------------
when I click to sort the Volume cloumn or price column the sorting not correct .
I assume setting style isn't relevant for sorting. Since your data is a string, it compares like a string. If you can edit your class, create two properties of type double that will cast the original properties and show only them in the grid. If you can't, you can create your own sort comparer an set it as the column.SortComparer.
public class GridCellComparer : IComparer<UltraGridCell>, IComparer
{
#region IComparer<UltraGridCell> Members
public int Compare(UltraGridCell x, UltraGridCell y)
IComparable xValue = double.Parse((string)x.Value);
IComparable yValue = double.Parse((string)y.Value);
if (xValue != null && yValue != null)
return xValue.CompareTo(yValue);
return x.Text.CompareTo(y.Text);
}
#endregion
#region IComparer Members
public int Compare(object x, object y)
return Compare(x as UltraGridCell, y as UltraGridCell);
I understand you'r point but i don't know where exactly call this class : GridCellComparer
may be like this :
"Price"].SortComparer = GridCellComparer
Yes. Does it work?
Hi,
You don't need two columns. All you have to do is write a SortComparer. Create a class (or use an existing class) which implements IComparer. This interface has a single method: Compare.
The Compare method will get called whenever you sort and all you have to do is return a value which indicates which of the two values passed into the method is higher/lower.
When you assign an IComparer class to the grid column, the grid will call into your comparer and pass you two UltraGridCell objects. So you could use the value or text of those cells, or you can use the cell object to get other cells in the same row and evaluate to whatever sort order you want.
i don't know if this is the same case but i tried everything to no avail.
I have a simple problem that has been annoying me for the last month..i hope you can help me with it.in my UltraWinGrid (grdBOQ) i have a column called "FUllName" that contains product names like: (CC3, CC2, CC12, CM2, XM23.)when i click to sort this column the result comes as: CC12, CC2, CC3, CM3, XM23.(which is wrong for me but i understand because this is a string sort.)The correct order should be CC2, CC3, CC12, CM2, XM23.i managed to get two respective columns from database that show the split of this column, they are:ProdDesc (data of type string) = CC, CC, CC, CM, XMandProdNum (data of type int) = 12 , 2 , 3, 3, 23so FullName is split into ProdDesc and ProdNum ( xm23 = xm, 23) but i don't want to show the last two columns to users.i want the user to view ONLY FullName and click its header to get the grid sorted by (ProdDesc then ProdNum consecutively).can u please provide me a solution??Your help is Extremely appreciatedThanks
You would call this method when you want to programmatically sort the data in the grid. Any time after you set the grid's DataSource and have loaded all of the data into your DataSource should be fine.
in which method are we supposed to call this class??
grid_BeforeSelectChange or when/?
don't wory .:)