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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do you group and sort when the form of the object is unknown until runtime?

Thread ID:





47311 Aug 2,2006 02:46 PM UTC Aug 9,2006 01:14 PM UTC WinForms 2
Tags: Grouping
Kenneth Vrana
Asked On August 2, 2006 02:46 PM UTC

- Or how do you group and array of objects?

I have a situation where I need to group and sort data that can change form during runtime. I basically have an ArrayList of ArrayLists. That data takes the form of the outer ArrayList being the rows, and an inner ArrayList being the columns. For example the data will look like this:

m_data = new ArrayList(8);
MyList inner;

inner = new MyList(3);
inner.Add(new SampleData("Ray"));
inner.Add(new SampleData("Red"));
inner.Add(new SampleData("42"));

inner = new MyList(3);
inner.Add(new SampleData("Joe"));
inner.Add(new SampleData("Black"));
inner.Add(new SampleData("66"));

The number of columns can change, but they will always be made up of the same object. The columns that are grouped and sorted will change.

I took the approach of using a custom Categorizer, and this works fine if I only group on one column, but not on two or more. I suspect that I will need my own Comparer, but I don’t have enough context to know what values I need to compare. It seems that the SortColumnDescriptor name is used as the property name for the object. How can I use a different name for the SortColumnDescriptor that is used to obtain the property value that is used for the sort?

I have enclosed a simplified version of the code that demonstrates things better then I can explain then in text.



Kenneth Vrana
Replied On August 2, 2006 03:18 PM UTC

The sample code has an error in SetupGrouping() where the first line in the method where "Val" is bing added as a GroupedColumns should be removed. This is why one of the groups worked, where now none of them do.

Administrator [Syncfusion]
Replied On August 9, 2006 01:14 PM UTC

Hi Ken,

Sorry for delayed reply. In the main list (m_data), the only public property is Me. So, that is the only thing the engine can see, and the only thing that can be sorted easily. So, one way to manage this is to have the MyList class implement IComparable. This will allow you to control how the Me property gets sorted. If you want to sort it on several of the objects in the actual child list, then you can make the IComparable implemetation do this. Attached is a modified sample to do a multiple column sort. But since the engine is not exposed to any other property(column) directly, its not possible to add columns in the GroupedColumns collection. Let us know if you need any further assistance.




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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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