Infragistics UltraGrid and Band order that depend from the bindingManager

Posts   
 
    
Max avatar
Max
User
Posts: 221
Joined: 14-Jul-2006
# Posted on: 18-Aug-2006 09:17:34   

Hi, I'm using Infragistics UltraGrid to show and edit my data. My data is composed from a RootEntity with some subEntityCollection. (Customer --> Address, Customer --> Email, Customer --> Phones)

So I fetch my data, I bind my data do BindingSource object, ad I bind UltraGrid to BindingSource object.

Everithing is fine, I see my RootEntity in band 0, ad subEntityCollection in band 1,2,3. simple_smile

Child bands are show in this order disappointed Band 1 = Email Band 2 = Address Band 3 = Phones

Now I want to change this order. In this Gui I want Band 1 = Address, Band 2= Phones, and Band 3 = Email.

Infragistisc tell that there isn't any way to change the band order rage , the band are show in the order they are returned by the binding manager. frowning

So, I need a system to change the band order.

How can I change the order in wich the BindingManager return the EntityCollection?

I need to be able to decide the order at runtime, because I can have different gui showing different subset of the same data, but in different order (order of the band). Is this possible?

Thanks, Max

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39873
Joined: 17-Aug-2003
# Posted on: 18-Aug-2006 10:00:32   

No I'm afraid it's not, unless you use your own build ORMSupportClasses dll (build from the sourcecode provided) and alter the GetItemProperties method in EntityViewBase (and / or derived classes) and order the stuff in the order you want them to have.

I've never seen a requirement to have the bands in a given order though.

Frans Bouma | Lead developer LLBLGen Pro
Max avatar
Max
User
Posts: 221
Joined: 14-Jul-2006
# Posted on: 18-Aug-2006 10:55:46   

We need a particular band to be under the root band. because the data that come from entity X must be shown as if they were part of the root entity.

So we need that band of entity X is exactly under the root band, so we can format Band X like RootBand, and create a layout that permit to the user to visibily understand that RootEntity and EntityX are the same data, like if the were a single entity.

This is our strong requirement.

A les strong requirement, but still important, is that our application will be used by different customer: it could be tha customer A want to see band in order Address/Phones/Email, when the customer B (that is more internet-centric) want to se the band in order Email/Address/Phones.

Whati if I wrap the method GetItemProperties? I can use the original method to get the collection and, starting from the original collection, create a new one changing the order of the items? Will this work? or maybe that this will broke something due to some logic based on the original collection object order?

Thanks, Max

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39873
Joined: 17-Aug-2003
# Posted on: 18-Aug-2006 17:43:43   

GetItemProperties is one of the ITypedList methods, the interface used for type discovery in winforms binding. So the bound grid will call this method. IF it plays nice. Infragistics wasn't always nice in this, they sometimes simply reflected over the properties of the first item in a bound collection.

So IF you want to be able to control the order of the collections reported, you have to sort the property descriptors returned by that method in one way or the other, but likely it won't work with infragistics.

Frans Bouma | Lead developer LLBLGen Pro
Max avatar
Max
User
Posts: 221
Joined: 14-Jul-2006
# Posted on: 21-Aug-2006 09:52:48   

Thanks for the info. simple_smile Thanks to your hints now I'm working on a solution based on a personalized BindingSource. I'm working on a wrapper that reorder the idems returned bue BindingSource.GetItemProperties.

I have just made some test, and the results look promising sunglasses

Working on BindingSource class seem simpler to me. I' will not mess up with your code :-), and I only need to use a different class for BindingSource.

Thanks, Max

Max avatar
Max
User
Posts: 221
Joined: 14-Jul-2006
# Posted on: 22-Aug-2006 11:33:20   

I've done the override of GetItemProperties method, in a class derived from BindingSource. It works! sunglasses

I post a reduced method to show the concept. It's only an example. It probabily need more test and check.


    Public Overrides Function GetItemProperties(ByVal listAccessors() As System.ComponentModel.PropertyDescriptor) As System.ComponentModel.PropertyDescriptorCollection
        Dim OldPDC As System.ComponentModel.PropertyDescriptorCollection
        Dim Ret As System.ComponentModel.PropertyDescriptorCollection

        Dim mLLBLInterfaceName as string = GetType(SD.LLBLGen.Pro.ORMSupportClasses.IEntityCollection2).FullName


        'Work only on root object
        If listAccessors Is Nothing Then
            'get original collection of PropertyDescriptor
            OldPDC = MyBase.GetItemProperties(listAccessors)

            'check if there is some item
            If OldPDC.Count > 0 Then

                'temp array
                Dim TempPropArray(0 To (OldPDC.Count - 1)) As System.ComponentModel.PropertyDescriptor

                Dim c As Integer
                Dim NewPropIndex As Integer

                NewPropIndex = 0
                For c = 0 To OldPDC.Count - 1

                    'Check the type of PropertyDescriptor
                    If OldPDC(c).PropertyType.IsGenericType AndAlso (OldPDC(c).PropertyType.GetInterface(mLLBLInterfaceName) IsNot Nothing) Then
                        'do the stuff with LLPLGen properties descriptor

                        '...remapping
                        '...remapping
                        '...remapping

                    Else
                        'Normal properties descriptor
                        TempPropArray(NewPropIndex) = OldPDC.Item(c)
                        NewPropIndex = NewPropIndex + 1
                    End If
                Next

                'create a new properites collection based on the remapped array
                Ret = New System.ComponentModel.PropertyDescriptorCollection(TempPropArray)

            Else
                'return original collection, it's empty
                Ret = OldPDC
            End If


        Else
            'return original collection, I'm not working on root object
            Ret = MyBase.GetItemProperties(listAccessors)
        End If

        Return Ret
    End Function

Bye, Max

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39873
Joined: 17-Aug-2003
# Posted on: 22-Aug-2006 11:50:04   

Cool! Great you found a solution simple_smile

Frans Bouma | Lead developer LLBLGen Pro