Hello,
When i try to sort my grid on a custom (date) property, i get a weird behavior where it doesn't quite sort the dates. It appears to break the sort into 2 parts. top to middle is sorted, and than from middle to bottom is a separate sort. i.e. april 1 - may 7th.. than from middle it appears to start again april 9th - may13th etc..
It may be because i am binding the grid to List<MyPosition>, and MyPosition date member is not actually a DateTime type. it is an Object. I have it that way because i use shared base type functionality. I overwrote all the necessary interfaces so that it is treated like a DateTime by the rest of the framework, but Infragistics grid seems to be tripping on it. My Grid is version 8.2
here is my base type implementation (the object i use instead of DateTime):
http://paste.bradleygill.com/index.php?paste_id=9282
I use that base type to serve as base to all date parameters such as:
public class TradeDate : QueryDateTimeParameter {...}public class SettlementDate : QueryDateTimeParameter {...} etc..
and than, I have a Position object:
public class PortfolioPosition { public TradeDate Date { get; set; } public InterestParameter Interest {get; set;} etc...}
than i use a List<PortfolioPosition> which is the collection bound to the grid.
My sorting code:
PositionsGrid.Bands[0].SortedColumns.Add( myColumn ); myColumn.SortIndicator = SortIndicator.Ascending;
That columns DataType property is set to DateTime, but grid doesn't seem to care about it. I am wondering how does it know what kind of sort to perform (alphabetic, numeric, date.. etc)
Hi
I have also achieved column level sorting. The process is divided into following steps
1. For a column that is bound :
- define algorithm as custom, ascending as the indicator
- define implementation as the delegate
- Add column to sorted columns. (this triggers the sort)
2. Implement a delegate
3. Inside delegate define System.Collections.Generic.SortedList<Key,Value> with IComparer<Key> class defined with the rule for sorting two items.
It works fine.
Regards
I am assigning it in the exact same manner as the example
_grid.DisplayLayout.SortingAlgorithmDefault = SortingAlgorithm.Custom;_grid.DisplayLayout.SortImplementation = new SortRowsCollection(ApplyCustomSort);
the reason i am comparing the Value is because i want a different comparison to happen depending on the underlying data type. cell.Value.Compare will execute underlying type IComparable.Compare so i don't have to worry about datetime being sorted alphabetically etc
How do you assign SortImplementation property? Is it at column level? Could you please share that code?
Also think about this:
You are comparing cell.Value. But it may happen that for some of the columns you are binding the value list. In that case comparing the Cell Text is more logical then cell value. Your code needs to change to handle such value list columns.
cell.Value
ok i figured out how to use custom sort..
this works.. but i am not completely happy as i wish i didn't have to implement this since my collection properties implement IComparable.. but i guess it is something. Here is my implementation of Infragistics custom sort (replacing that retarded example provided by infragistics)
http://utilitybase.com/paste/13690
ok,
i got infragistics custom sort to work. As long as there is no group by, it is fine (I already had this part figured out with sorting of the collection before binding to grid)
as soon as i add a group by, it breaks the order in the output. Meaning group by shows multiple times:
Group 1 row rowGroup 2 row rowGroup 1 rowGroup 1 row row row
etc.