I have a class that implements a searchable and sortable binding list (called SearchableSortableBindingList). When I bind such a list to a Datagridview, I get the ability to sort my records in ascending or descending order when I click a column header.
A few weeks later I discovered CSLA and started learning it. I belive in CSLA, you use BusinessListBase when you want a list of your business objects. However, this class does not have the functionality as in my SearchableSortableBindingList class.
Can someone explain to me how I can incorporate my class with CSLA? Or point me in the right direction?
Thanks !
Ray
You want to use the SortedBindingList. Basically you create it and pass in your BusinessBase Collection. Then you bind the SortedBindingList to the datagridview and now it is sortable!
You can use SortedBindingList and/or FilteredBindingList if you only need single property sorting.
I decided to use the excellent ObjectListView (in CSLA Contrib) because it allows sorting and filtering in the same class with multiple property sorts as an option. Very easy to use.
Bottom line - Rocky decided that modifying the existing List was a bad idea and changed it in CSLA2 so that you can View the list instead. All 3 classes mentioned above support this view concept.
Joe
I can't seem to find ObjectListView.
Can you tell me where I can find it?
Thanks !
rayc:I can't seem to find ObjectListView.
Can you tell me where I can find it?
Thanks !
This thread discusses it:
http://forums.lhotka.net/forums/thread/10559.aspx
Code can be found here:
http://www.codeplex.com/CSLAcontrib/SourceControl/ListDownloadableCommits.aspx
Go there and download the most recent version. You should be able to find the necessary files in there.Extract the zip file into folders and delete all the stuff you don't want and keep:
\Csla2Extensions\ObjectListView\CSharp
I copied them to a new folder structure and created a separate project so I could reference the binaries in my real app. It also allowed me to change the namespace to Csla2 the other day and re-compile. I normally like to convert C# to VB but there is a lot of code here and it is fully tested - I would be afraid of introducing a bug. Brian said he was thinking of doing the conversion but it is a lot of work and not really needed as long as you can reference the binaries.
Joe
From Rocky's book I have the following:
public class InvoiceList : ReadOnlyListBase<InvoiceList, InvoiceInfo>
{
public static InvoiceList GetInvoiceList()
{
return DataPortal.Fetch<InvoiceList>(new Criteria());
}
...
}
So I modified it to look like this:
public static InvoiceList GetInvoiceList()
{
InvoiceList _invoiceList = DataPortal.Fetch<InvoiceList>(new Criteria());
SortedBindingList<InvoiceList> sortedList = new SortedBindingList<InvoiceList>(_invoiceList);
return sortedList;
}
The problem I'm having is that I'm trying to take the list returned by the DataPortal.Fetch and converting it to a SortedBindingList.
But this doesn't work. The compiler isn't able to convert from one to the other. What am doing wrong?
Thanks in advance
I had tried that but I kept getting error CS1502:
The best overloaded method match for Csla.SortedBindingList<Accounting.Invoice>.SortedBindingList<System.Collections.Generic.IList<Accounting.Invoice>> has some invalid arguments
The same line also gives me the error CS1503:
Argument '1' cannot convert from 'Accounting.InvoiceList' to 'System.Collections.Generic.IList<Accounting.Invoice'
Copyright (c) Marimer LLC