StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      


«««12345»»

How do I filter a business object by a custom...Expand / Collapse
Author
Message
Posted 06/26/2008 2:04:34 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 4:11:57 AM
Posts: 4,586, Visits: 4,570
One other point that I saw in regards to your grid...if you do not have a custom property descriptor setup, it will not show up in a grid.  You will need to override the GetCustomBindablePropertyDescriptors method on the BO and provide a ReflectionPropertyDescriptor.
Post #17398
Posted 06/26/2008 2:05:22 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 1:30:54 PM
Posts: 437, Visits: 1,754
Here is my actual custom property code.  Please criticize at will.  I have no other code reviewer here.  There has got to be something fundamentally wrong with what I am doing so that none of the custom properties values are showing up in a DevEx XtraGrid (via BBS).  I have done this with several other BOs so the process is not new to me. 

From these custom properties, I would like to filter the grid on the spxRequiredQty value.  Somehow, I have to tell the underlying table of the BO that the column exists and what the data actually is (without resorting to stored procs and such). 

I know I am being difficult with this.  I have tried so many things that all of this is becoming a blur.  I have read through this thread several times, but just cannot see the light.  Thought I did a few times, but it was just that proverbial debug train coming at me through the tunnel of code exceptions.

Bill

P.S. Still using SQL Server 2000. 

  Post Attachments 
mycustompropertycode.txt (14 views, 4.21 KB)

Post #17399
Posted 06/26/2008 2:05:26 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 2 days ago @ 2:54:01 PM
Posts: 359, Visits: 2,322
Bill,

Try taking the business binding source out of the equation, just throw a few text boxes on a form bound to your business object custom properties  fill it and navigate through your record set and see if it works.

The business binding source can create some serious migraine style headaches as it creates a new instance of the business object for each row so some things that have been set in the original BO are not longer "set" in the newly created bo.. Try it withough the BBS and see if your logic works. 

If it works without the BBS in the middle then you can play doctor with the BBS source code and create a BBS specific to the business object you are binding to.

Paul

Post #17400
Posted 06/26/2008 2:19:20 PM


Advanced StrataFrame User

Advanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame UserAdvanced StrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 2:16:04 PM
Posts: 703, Visits: 11,233
Hey Bill.

Just in case it might help you see what Trent told you about adding a new field to your table and filtering on it, here is some code of mine where I do exactly the same, filtering on a field that doesn't exist on the underlying table.

On your BO:

    Private Sub MyBO_CurrentDataTableRefilled() Handles MyBase.CurrentDataTableRefilled
        If Me.CurrentDataTable.Columns.Contains("myField") = False Then
            Me.CurrentDataTable.Columns.Add("myField", System.Type.GetType("System.Boolean"))
        End If
    End Sub

    Private Sub MyBO_CurrentDataTableInitialized() Handles MyBase.CurrentDataTableInitialized
        If Me.CurrentDataTable.Columns.Contains("myField") = False Then
            Me.CurrentDataTable.Columns.Add("myField", System.Type.GetType("System.Boolean"))
        End If
    End Sub

And, of course, the property:

    <Browsable(False), _
     BusinessFieldDisplayInEditor(), _
     Description("My property"), _
     DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
    Public Property [myFieldProperty]() As Boolean
        Get
            Dim loValue As Object
            loValue = Me.CurrentRow.Item("myField")
            If loValue Is DBNull.Value Then
                Return False
            Else
                Return CBool(Me.CurrentRow.Item("myField"))
            End If
        End Get
        Set(ByVal value As Boolean)
            Me.CurrentRow.Item("myField") = value
        End Set
    End Property


    Protected Overrides Function GetCustomBindablePropertyDescriptors() As MicroFour.StrataFrame.Business.FieldPropertyDescriptor()
        '-- Create and return a new array of FieldPropertyDescriptor
        ' objects that contains the ReflectionPropertyDescriptor
        ' for the cas_Idade field.
        Return New MicroFour.StrataFrame.Business.FieldPropertyDescriptor() { _
            New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor("myFieldProperty", GetType(MyBO))}
    End Function

So, now, on my logic, after setting my field depending on conditions:

        '-- applies the filter
        Me.MyBO1.Filter = "myField = True"

Hope it helps in some way...

Post #17401
Posted 06/26/2008 2:20:47 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 1:30:54 PM
Posts: 437, Visits: 1,754
With the textboxes, the values are showing up properly as I navigate through the BO.

The grid has a BBS datasource that points to the exact same BO.  All of the fields in the grid are blank.

(preparing to look for a towel to throw in)

Post #17402
Posted 06/26/2008 2:37:52 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 1:30:54 PM
Posts: 437, Visits: 1,754
Hi Ivan,

Thanks for the input.  The only real difference is that my properties are read-only; therefore, no set portion.  I have done exactly what you did...except I did not put the add column code in both methods of the BO (initialize and refilled).  I will try that.

Bill

Post #17404
Posted 06/26/2008 2:53:29 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 2 days ago @ 2:54:01 PM
Posts: 359, Visits: 2,322
That is good, if it work's without the BBS then you know it is a BBS issue and not a business object issue.

What happens when you use a BBS is that it creates a new instance of the busines object for every row. However it does not carry over any custom properties etc that are to the new instance.for instance if you have a property called foo in you business object and its value has been set to "Something" what the business binding source create a new instance of the Bo for that row the property foo's value with be nothing.

If that is what is happening then you can fix it by creating a BBS that is customized to your business object type. If you rthink this is where your problem is i can send you a copy of one I modified.

Paul

Post #17407
Posted 06/26/2008 2:59:41 PM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: 2 days ago @ 7:28:14 PM
Posts: 1,280, Visits: 3,259
Bill,

You might try doing something real simply like just returning a constant, bypassing all the code in you properties to see if that works. i.e.
public decimal spxSalesOrderQty
{
get
{
// just skip the rest for now
return 1;

decimal mSOQty = 0;
...rest of code untouched
}
}


If this works, then it has something to do with the property code. If it doesn't, then is has to do with the properties themselves or how the grid is using those properties.
Post #17408