Filtered List

Filtered List

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


Wal972 posted on Saturday, November 11, 2006

Hi,

I have a Root BO and child collection with child BOs. So my question is this, how do I use the Filtered list to extract particular children. Is there a template for this ? and where do I have Filtered in my BO structure. ie as a child of the Root BO or something different ?

thanks

Ellie

dean replied on Sunday, November 12, 2006

Normally you would filter in the UI (or at least I do) but depending on your use case you could expose a FilteredList as a property in your root. Can you describe your use case?

Dean

RockfordLhotka replied on Sunday, November 12, 2006

You have to ask yourself whether the filtering is part of the use case, or a user convenience feature?

If it is part of the use case that only a filtered subset of data is available to the UI, then exposing a pre-filtered list from a BO would make sense.

If the use case doesn't care if the entire collection is available to the UI, then it isn't part of the business layer to deal with that issue. In this case (which is more common imo), the requirement really comes from the UI, not the business scenario. The user wants filtering to make their lives easier.

In this latter case, the UI should use FilteredBindingList to create a filtered view of the collection exposed by the business layer.

This same logic applies to sorting. If the business use case doesn't require sorting (which is relatively rare), then it is a UI issue, and should be handled in the UI layer.

Wal972 replied on Sunday, November 12, 2006

Thanks,

Is there are template on how to use it ? Is there any examples ? Its the UI that needs the filtering ASP.NET to be exact

RockfordLhotka replied on Sunday, November 12, 2006

I am working on an ebook for version 2.1 that should be available before the end of the year. That will describe the usage for all the new 2.1 features.
 
Rocky


From: Wal972 [mailto:cslanet@lhotka.net]
Sent: Sunday, November 12, 2006 2:23 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Filtered List

Thanks,

Is there are template on how to use it ? Is there any examples ? Its the UI that needs the filtering ASP.NET to be exact




Wal972 replied on Sunday, November 12, 2006

can't wait please do the vb.net one first

:) Thanks

Wal972 replied on Monday, November 13, 2006

Can anyone please help with an example for the filtered list. I need it really urgent, but I haven't got a clue.

thanks

RockfordLhotka replied on Monday, November 13, 2006

To use the default filter is pretty easy:

Dim list As New List(Of String)()
' populate with some data

Dim filtered As New FilteredBindingList(Of String)(list)
filtered.ApplyFilter(Nothing, "A")
' list now displays only items containing "A"

Using a custom filter is a bit harder, as you have to implement a filter method matching the FilterProvider delegate. This delegate is passed into the constructor of FilteredBindingList, or it can be set through the FilterProvider property.

Wal972 replied on Monday, November 13, 2006

I tried using that in the ASP.NET code behind loading code and it won't show the FilteredBindingList but in my BO it shows up ? Confused

RockfordLhotka replied on Monday, November 13, 2006

Make sure you set e.BusinessObject equal to your filtered list, not the original. Like SortedBindingList, FilteredBindingList is just a view over the existing list, which is entirely unchanged by this process.
 
Rocky
 


From: Wal972 [mailto:cslanet@lhotka.net]
Sent: Monday, November 13, 2006 2:40 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: Filtered List

I tried using that in the ASP.NET code behind loading code and it won't show the FilteredBindingList but in my BO it shows up ? Confused


Wal972 replied on Tuesday, November 14, 2006

Helps when I Import the CSLA into the Web Page Code Behind.

Thanks for the help

Copyright (c) Marimer LLC