Sorting and Filtering a single list

Sorting and Filtering a single list

Old forum URL: forums.lhotka.net/forums/t/1430.aspx


jphegarty posted on Tuesday, October 10, 2006

Hi All

I am newish to using CSLA, I am looking to implement the functionality from the sortedbindinglist from an earlier version and the latest filteredbindinglist from version 2.1

I am able to get these working individually (Can sort a sorted binding list, Can Filter a filtered binding list)

The trouble i am having is when trying the sort and filter the same list.

I have tried to bring some code into filteredbindinglist from sortedbindinglist to apply the sort to this list but i get a notAllowed exception as SupporstSorting is False in IBindingList.SupportsSorting

Is there a way of using the functionality from these two classes with one list in the UI or do i need to merge the underlying filteredbindinglist and sortedbindinglist classes

Any help would be greatly appreciated as I am struccling with this one for quite a while and need to sort it out once and for all

Thanks

RockfordLhotka replied on Tuesday, October 10, 2006

You can use them in combination - you don't need to merge their code (which would be quite hard).

Dim x As New List(Of String)

Dim s As New SortedBindingList(x)
s.ApplySort()

Dim f As New FilteredBindingList(s)
f.ApplyFilter("Test")

The result is a sorted, filtered list: f.

jphegarty replied on Tuesday, October 10, 2006

Thanks Rocky, thats great

Copyright (c) Marimer LLC