Parent / Child Relationships


Author
Message
Crones
Crones
StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)
Group: Forum Members
Posts: 35, Visits: 345
I'm using the the DevExpress XtraGrid to view a list of contacts and I am trying to add a custom unbound field to display a value from a child record but I am having trouble getting the proper value.

Here is how I am setup:
2 BO's. Contacts & ContactPhoneNumbers on the form with the primary being the contacts.
The parent/child relationship is established and I've set the ParentObject on the ContactPhoneNumbersBO to Contacts.
The Contacts ChildAutoFilterOption property is set to MatchCurrentRow

The Contacts BO is attached to the grid via a BusinessBindingSource object.

I'm loading the Contacts BO and also the ContactPhoneNumbers BO using a custom Fill method which retrieves only the "primary" phone number for the contacts so pretty much all contacts and appropriate phone numbers are loaded during the contact's ParentFormLoading event.

What keeps happening is when the grid executes it's CustomUnboundColumnData event, I'm not able to access the child records.

Here is the event code I am using:


        Private Sub gvMain_CustomUnboundColumnData(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs) Handles gvMain.CustomUnboundColumnData

            Select Case e.Column.FieldName
                Case gcPhoneNumber.FieldName
                    Dim oCurrentContact As Database.ContactsBO = CType(bbsContacts.Item(e.ListSourceRowIndex), Database.ContactsBO)

                    If (oCurrentContact.ChildBusinessObjects.Count > 0) Then
                        e.Value = CType(oCurrentContact.ChildBusinessObjects(0), Database.ContactPhoneNumbersBO).PhoneNumber
                    End If
            End Select

        End Sub

Can you point to what I am doing incorrectly?

TIA

Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I was struggling with XtraGrid custom unbound column with SF BO/Businesss BindingSource for a month. Even thought, DevExpress team try very best to help me on this issue (I sent my whole project to them for troubleshooting) also no luck. Beside, it also will cause a lot of strange behavour. According to DevExpress team, SF BO behavour is not as their expected. I have posted such a lot info to SF team, but I haven't get any news yet.



Anyhow, I would said that, you would not able to access you BO record correctly in CustomUnboundData event. It always point to the same record.



Try to try custom field for your child BO field, and bind it to XtraGrid directly.



HTH
Crones
Crones
StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)StrataFrame Beginner (43 reputation)
Group: Forum Members
Posts: 35, Visits: 345
I'd prefer not to query the database for each child record field to create the custom field (unless I'm missing something there), I'll utilize a view and create custom insert/update procedures.  Not my first choice, so if anybody else has a better option please let me know.

Thanks!

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
A view is probably a good direction to go.  You are welcome to send us a sample project that replicates the behavior that you are talking about.  We do not use DevExpress in-house, but if we can see a sample that points to the problem, then we can see if there is an easy solution as to what is going on with the grid and our BO interaction.  This probably falls more on the side of the Grid as long as you have the BBS attached to the grid as the data source.  But at any rate, send a sample and we will look at it in more depth.  Thanks. Smile
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