Home › Forums › WinForms controls › Xceed Grid for WinForms › Custom sorting IComparer only called when sort direction is Ascending (bug?)
-
AuthorPosts
-
#17423 |
I have implemented a custom sorter and monitor the sort direction of the column using Column.SortDirectionChanged to create the illusion of fixed rows. What I need is to keep a certain order in a group while sorting. Say there are three types of values grouped together (value types A,B and C). I need to sort the A separate from the B which are in turn sorted separate from the C. Unfortunately, Compare is only called when the columns sort direction is Ascending (monitored during debug). Is this a know bug in the grid or might I have implemented something wrong? If the thought is this is in my implementation could you please provide a simple example that works properly?
Here is a quick sample to check this behaviour. It is just a VB.Net Windows Forms app with a single label dropped on it. When this is run it confirms what I saw while debugging in a larger application. The label text is only modified after the first click on the column header at which time its text is changed to Ascending. It never changes after this.
Imports Xceed.Grid
Public Class Form1
Private grid As GridControl
Private WithEvents Col1 As Column
Private ColManagerRow As ColumnManagerRow
Private Colmanager1 As ColumnManagerCell
Public mSortDirection As Xceed.Grid.SortDirection
Dim isorter As sorter
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim newrow As DataRow
grid = New GridControl
Me.Controls.Add(grid)
ColManagerRow = New ColumnManagerRow
Colmanager1 = New ColumnManagerCell(“Col1”)
grid.Size = New Size(Me.ClientSize.Width – 20, Me.ClientSize.Height – 20)
grid.Location = New Point(0, 0)
Col1 = New Column(“Col1”)
grid.Columns.Add(Col1)
grid.FixedHeaderRows.Add(ColManagerRow)
Col1.CanBeSorted = True
Col1.Visible = True
Col1.Title = “Col1”
isorter = New sorter(Me)
Col1.DataComparer = isorter
For i As Integer = 1 To 10
newrow = grid.DataRows.AddNew()
newrow.Cells(“Col1”).Value = “Col1Row” & i
newrow.EndEdit()
Next
End SubPublic Class sorter
Implements IComparer
Public mowner As Form1
Public Sub New(ByVal Owner As Form1)
mowner = Owner
End Sub
Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
mowner.Label1.Text = mowner.mSortDirection.ToString
End Function
End ClassPrivate Sub Col1_SortDirectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Col1.SortDirectionChanged
mSortDirection = Col1.SortDirection
End Sub
End ClassImported from legacy forums. Posted by David (had 2702 views)
Hi David,
The observed behavior is normal: when a new sort is detected and that is the reverse of the previous one, we simply reverse the data order. This was done to get the maximum performance; however, we agree that it is not suitable for your situation.
Unfortunately, we do not have a workaround to provide that would fit exactly your specifications.
Imported from legacy forums. Posted by Mohamed [Xceed] (had 361 views)
That is very bad news. Back to searching for a workable solution then I guess. Thanks anyway.
Imported from legacy forums. Posted by David (had 635 views)
Hi, any news. Ive got a similar prob….
Imported from legacy forums. Posted by tm (had 575 views)
I am looking at this again and hoping there has been a change that would allow this type of implementation. Can this be accomplished using XCeed or should I look elsewhere for a workable solution? Let me rephhrase that. I really like the grid but not being able to keep items grouped as I wished is a deal breaker.
Imported from legacy forums. Posted by David (had 369 views)
Hi David,
Can you email me a sample at support@xceed.com so that I may investigate further. You can put a reference to this forum post so that I know that it is you who will be emailing
Imported from legacy forums. Posted by Marc [Xceed] (had 213 views)
Sent.
Imported from legacy forums. Posted by David (had 1693 views)
-
AuthorPosts
- You must be logged in to reply to this topic.