By Andria Jensen - 7/13/2009
Do you guys implement IListServer for the BOs and if not, can you point me in the right direction of how to implement this myself? We are are generating a few really large datasets and it is taking a while to render them without having this implemented. Thanks!
|
By Trent L. Taylor - 7/14/2009
No, we don't. But you will not want to implement this on a BO directly. You would actually want to implement this on a Custom Binding Source or something along those lines. If you recall, you must call the GetEnumerable() to enumerate a BO and wrap a BO with a BusinessBindingSource to achieve the IBindingList for grid binding. So you will want to follow suite for implementing IListServer. IListServer, if I am not mistaken, is a DevExpress implementation, not .NET. They do this to achieve paging within their grids. I have heard of mixed reviews of trying to implement this, but in any case, it is specific to DevExpress, thus not something that we will implement directly within the framework as this would require too low of a hook. But I would create a custom BBS, then implement the IListServer there most likely. I have not tried this nor have I ever tried to implement this interface, but that should be a good starting point.
|
By Andria Jensen - 7/15/2009
Ok, here we go...I'm getting somewhere with all of this. Just implementing these two gets the data returning back correctly. However, there are still a bunch of others to implement grouping, sorting, etc. Public Function GetRowIndexByKey(ByVal key As Object) As Integer Implements DevExpress.Data.IListServer.GetRowIndexByKey Return Me.BusinessObject.CurrentView.Find(key) End Function Public Function GetRowKey(ByVal index As Integer) As Object Implements DevExpress.Data.IListServer.GetRowKey Return Me.BusinessObject.CurrentDataTable.Rows(index).Item(Me.BusinessObject.PrimaryKeyField) End Function This is what I am using for sorting and it is working, but NOT for custom properties. How do you do a sort in code for the custom property or can you??? I know the BBS handles this for you, but not sure how to do it myself. Any suggestions? Public Sub ApplySort(ByVal sortInfo As System.ComponentModel.ListSortDescriptionCollection, ByVal groupCount As Integer, ByVal summaryInfo As System.Collections.Generic.List(Of DevExpress.Data.ListSourceSummaryItem), ByVal totalSummaryInfo As System.Collections.Generic.List(Of DevExpress.Data.ListSourceSummaryItem)) Implements DevExpress.Data.IListServer.ApplySort
If sortInfo IsNot Nothing Then
Dim sortString As String = ""
For Each info As ListSortDescription In sortInfo sortString &= info.PropertyDescriptor.Name & " " & IIf(info.SortDirection = ListSortDirection.Ascending, "ASC, ", "DESC, ") Next
Me.BusinessObject.Sort = sortString.TrimEnd(",", " ")
End If
End Sub
|
By Trent L. Taylor - 7/15/2009
How do you do a sort in code for the custom property or can you???
This logic will be entirely up to how you handle the code behind the custom property. Back to basics first, a BO.Sort uses the CurrentView.Sort property. So the sort is ultimately handled in the ADO.NET table behind the BO.
Depending on how you are sorting, then you can either force a column into the CurrentDataTable for sorting purposes, or if there is an IComparer option, you can do anything you want. This would allow you to pull the logic out of the standard BO sort. I don't have any first hand experience with the IListServer interface, but the IBindingList implementation may be a similar comparison in regards to the Sort implementation. In this case, in a BBS, we rely on the sort of the BO, not recreating an internal sort.
Don't know if any of this helps, but this isn't an easy to answer question because there are a lot of factors that can be involved.
|
By Andria Jensen - 7/15/2009
They show their example using an ArrayList and sorting via an IComparer. How would I use an IComparer with the BO DataTable? I have tried creating an ArrayList of BOs and it will sort correctly with the IComparer I have implemented, but I don't know how to get it set back to the CurrentDataTable again from the ArrayList. I may be way off in how I'm approaching this though, so if you have any advice for implementing the IComparer for a BO that would be awesome.
|
By Trent L. Taylor - 7/16/2009
Well, giving you a sample is going to require a little elbow grease, but in short, you would produce an internal sort array within your IListServer implementation. For example, you will know the field or column that needs to be sorted, so you would create a two part class and collection with a customer IComparer class that would sort and save off the row index so you know how to deal with the BO records. For example,
Sort Item Class (Pseudo Code)
Public Class MySortClass
Object SortValue
int RowIndex
End Class
Then you will need a collection:
Sort Item Collection
Public MySortCollection
Inherits System.Collections.CollectionBase
'-- Within this class you will create a sort method and the IComparer is already implemented, so you just need to create an IComparer
' class to pass over to the sort that will support your MySortClass logic and structure
End Class
Keep in mind that you will have to most likely pass over a BO at some point here as well (or at least the current row index of the value when the MySortClass item is created. But this will create a sorted collection that is in the right order. You can then either show the collection and when a collection item is selected, it updates the underlying BO row index, or re-order the BO once you know the order of the collection.
Like I said, this is not the easiest thing to just slap out an explanation for as there are a lot of factors, but these are just some possible ideas.
|
By ChanKK - 6/12/2010
Hi
Any further info could be shared? Or any alternate way to implement server mode like LINQ to BO?
Thank you
|
|