How do I filter a business object by a custom property?


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
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.  Blush

Attachments
mycustompropertycode.txt (185 views, 4.00 KB)
Paul Chase
Paul Chase
Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
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

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
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...

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
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)

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
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

Paul Chase
Paul Chase
Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
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

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
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.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Paul:  I have a very similar setup on my InvoiceBO with the [invoicetotal] field.  It is a custom property and displays nicely on a grid via a BBS.  I am mimicking much of what I did there within this current BO.

Greg:  I returned only a constant and the value still are not showing up in the grid.  Disturbing.  For some reason, as Paul is alluding to, the BBS is not picking up these values and passing them to the grid.

Guys...thanks for all of the help.  I am hitting the 24 hour mark on this current problem.  Hopefully, it will get resolved soon. 

Btw, I have eliminated any column adding and filtering options...I need to get the data flowing first to the grid.  I will go from there once that is back in business.

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
BILL, if you would read my previous post, there is ONLY one reason it would not show up in a grid through a BBS.  You are missing a property descriptor for the custom property...period!

You may be dealing with post and information overload, but this is not an overly complicated process or problem...when I run into something like this it is generally due to frustration and dealing with the same problem over a period of time.  There is a lot of good information in this thread...but first things first, I had posted explaining how to ensure the column always exists within the CurrentDataTable.  Secondly, I have told you the one and only reason why a custom property would not be visible through the BBS.  Please check and refer to these two points and I am sure that you will see where your problem is.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search