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.
Syncfusion Feedback

CoveredRanges and SortByColumn

Thread ID:

Created:

Updated:

Platform:

Replies:

35710 Oct 6,2005 07:52 PM UTC Oct 7,2005 04:10 PM UTC Windows Forms 5
loading
Tags: GridControl
Clinton Nielsen
Asked On October 6, 2005 07:52 PM UTC

I noticed that when I use the SortByColumn command, the CoveredRanges don''t follow their respective rows. Is there some property I might not have set right, or how would I get the covered ranges to follow the rows during a sort? Thanks

Administrator [Syncfusion]
Replied On October 6, 2005 10:02 PM UTC

There is no property to try to do this. In general, this is problematic. Suppose you have a grid with 5 columns with column 1 having no covered cells; in col 2, row 1 and 2 are covered; in col 3, row 1, 2, 3 are covered; in col 4, row 1,2,3,4 is covered and in col 5, row 1,2,3,4,5 is covered. Then you sort column 1. Exactly how would the covered cells behave in this situation. In column 2, there is no guarantee that the cell 2 value which was coved by the 1,2 covered cell will be located under where the cell 1 value will be moved. I suspect there may be situations with covered cells where sorting might make sense. In such cases, you might be able to come up with a way to do it. One way to try to handle special sorting requirements is to use a custom Comparer.

Clinton Nielsen
Replied On October 7, 2005 03:03 PM UTC

Thank you, I had considered that just afer posting, and realised in a lot of situations it wouldn''t make much sense. It does in mine however because covered ranges are only across columns, not rows. So when I sort by a column, I''m expecting each row to have the same set of covered columns as it did before. I have since solved that problem. What''s happening now however is still a little bit undesirable. When I use SortByColumn(..), all of the data in the grid is moved to new locations (and that''s good), but then I have to move all of the covered ranges to match the data. The grid refreshes between the two sets of operations, and so the user, upon sorting, sees all of the data move, then sees all of the covered ranges move. Is there a way to force the grid not to update the display until I tell it that it may? I tried using SuspendChangeEvents(), and SuspendLayout(), but neither seemed to work. Thanks again.

Administrator [Syncfusion]
Replied On October 7, 2005 03:57 PM UTC

Try calling grid.BeginUpdate before you sort and then call grid.EndUpdate after you have moved the covered cells. (You may also need to call grid.Refresh after EndUpdate.) If this does not work (and in a GridDataBoundGrid it does not, but it may work ok in GridControl), then there are general .NET ways to stop a control from painting that will likely work. If this is a GridControl (non-virtual), then you could handle teh problem of teh covered cells moving with the sort by not explicitly setting teh cells into grid.CoveredRanges. Instead, you could encode whether a cell is part of a covered range using the style.Tag. Then you could use grid.QueryCoveredrange to dynamically set the covered ranges. This only makes sense in the 1-row ranges that you said you were using. Here is the GridControlSort sample modified to show this idea. http://www.syncfusion.com/Support/user/uploads/CS_a661ac04.zip

Clinton Nielsen
Replied On October 7, 2005 04:02 PM UTC

Yes, that worked perfectly. Thanks so much!!!

Clinton Nielsen
Replied On October 7, 2005 04:10 PM UTC

One last (small) thing... More of a feature request than actually. Would you please consider changing your SortByColumn algorithm to implement a stable sort. Right now, if my grid is sorted by a column, then I resort by the same column and same sortdirection, some of the rows (with equal values) move around. Obviously this is undesirable as it is confusing to the user. A stable sorting algorithm would also allow for secondary and tertiary sorts, without actually having to add any code. Right now my IComparer is built to stabilise the sort in the case of equality (though to do so I had to add extra data to remember where things were), but a stable sort would definately be preferable. Thanks again!

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.

Warning Icon 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.Close Icon

;