Sorting Listview


Author
Message
Mark Dowlearn
Mark Dowlearn
StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)
Group: Forum Members
Posts: 34, Visits: 9.9K
My experience thus far indicates that in a when a field is processed within a listview so that it includes a format string or uses the "PopulatedThroughEvent" method, the sorting does not accurately reflect the base value.

For example, if I'm sorting on a name column and want to add a format string (<a href= "... ) to make the name be a link when viewed on the web page, the sorting gets messed up and does not display the list properly.

Has anyone else experienced this also?  If it's by design, then I request that the design be changed <smile>.

At least in the case of creating a hyperlink, I would have expected that the sorting would still be on the base value of the field (or whatever the displayed text of the link is if the two are not the same), but this does not appear to be the case.

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
The basic ListViewItemSorter in the framework can only see the text values of the ListViewItems in the ListView.  The sorter does not know about the data.  So, if you want to be able to sort off of the data and not the text within the view, then you'll have to write your own sorter.  The ListViewItemSorter property of a list view just accepts an IComparer object, which is easy enough to implement.
Mark Dowlearn
Mark Dowlearn
StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)
Group: Forum Members
Posts: 34, Visits: 9.9K
Hello, Ben - thanks.

I guess if that's the case, I'm wondering if a feature request for the framework would be to have a flag property on the ListView item that indicates the framework should parse the format string (or the DisplayValue set in a RowPopulating event) for just the displayed text rather than the entire string that includes markup and then use that for the sort functionality.

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Actually it will already do this intrinsically for a Date or Date/Time value.  As Ben mentioned above, we have a ListViewItemSorter class that you can implement as the ListViewSorter on a ListView.  This class, which you can look at since you get the source, is an IComparer implementation which sorts on character data while testing for date values and sorting correctly there.  If you need more functionality, it is very easy to write a comparer class as there is only a single method that you have to write that compares two values to see which one should rank higher.  You can also look at the ListViewItemSorter class to see what we did and you can expand on that if you have the need.  This would be your fastest solution.
Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

How to do this for browseresult? Which event to handle? Any sample for ListViewItemSorter class?
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yes, there is a ListViewItemSorter sample in the AdvancedListView sample (it might also be called SampleListViewPopulation). 

As for the BrowseDialog, I don't know that there is a way change the sorting on the BrowseDialog.  It currently uses the default ListViewItemSorter and the events have not been exposed for you to override the sorter that is used.

Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

Thank you for reply.



Hope you could provide some way to overcome this very soon, because my customer complaint that current date field sorting by ASCII is not making any sense.



Thank you
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search