StrataFrame Forum

Multiple Child BO Relationships

http://forum.strataframe.net/Topic16681.aspx

By Douglas Riley - 5/29/2008

I am having some difficulty establishing a relationship from a parent business object to two child BO's on the same form.  I have a customer (parent) business object linking to customer type and customer address business objects (children).  The child information is to be displayed in listviews for each one on a tabbed form.  I have gone through the steps of setting the ParentRelationship property on each child BO to point to the Customer BO.  I have also set the ParentBusinessObject property for each child BO instance on the form.  The ChildAutoFilterOption property of the Customer BO is set to "MatchCurrentRow."  The customer type BO populates its listview and I can cursor through the records and see the proper data.  The customer address listview does not populate.  Can a parent BO have two child BO's on the same form and be populated using the functions of Strataframe?  Any help would be appreciated!  Crazy Thanks!

Doug

By Trent L. Taylor - 5/29/2008

Can a parent BO have two child BO's on the same form and be populated using the functions of Strataframe? 

Sure, I setup one up the other day that had 8-10...with a lot of other foreign keys as well...so this is totally doable.

The ChildAutoFilterOption property of the Customer BO is set to "MatchCurrentRow." 

This could be your problem...using this in this scenario could come back and bite you.  Turn this off, then on the ListView, I assume you are using the CopyDataFrom method and then providing the BO and clone type on the ListPopulating event.  Before you set the e.Parameters(), set the filter:

ListPopulating Event

MyChildBO.Filter = "ForeignKey = " & ParentBO.PrimaryKey.ToString()

e.Parameters(0).Value = MyChildBO
e.Parameters(1).Value = MicroFOur.StrataFrame.Business.BusinessCloneType.ClearAndFillFromDefaultView

Then BE SURE TO CLEAR THE FILTER in the AfterRequery event:

AfterRequery Event

MyChildBO.Filter = ""

Doing this is far safer than leaving a filter on all of the time which can produce a lot of other side-effects (i.e. add a new record and rows change, etc).  Above would be the recommended way to setup this type of environment.

By Douglas Riley - 5/29/2008

Trent,

Thank you so much! That worked out fine!  Since I am using a maintenance form, does my parent business object have to have the IncludeInFormNavigate property set to true in order to coordinate movement?  Thanks

Doug

By Edhy Rijo - 5/29/2008

Trent L. Taylor (05/29/2008)

[quote]The ChildAutoFilterOption property of the Customer BO is set to "MatchCurrentRow." 

This could be your problem...using this in this scenario could come back and bite you.  Turn this off, ...

Hi Trent,

This is a bit confusing, I have a couple of forms which shows a Parent-Child relation using the ChildAutoFilterOption property, so far, it works fine, I have not noticed any problem yet, but with your suggestion I understand that this property should not be used? or there are specific cases for not using it?

Can you please elaborate on this, to clarify the use of this property.  I may have to go back and change some forms now BigGrin

By Trent L. Taylor - 5/29/2008

but with your suggestion I understand that this property should not be used? or there are specific cases for not using it?

I'll elaborate more on this in class and show what happens when you leave filters on.  Bottom line, if it is working for you, just leave it alone.

The problem comes when you add new records or change a field that is part of the filter...then you will start having strange behavior.  That was my point...secondly, you are going to have more control when you use the above technique over the auto-filter.  The whole point really has nothing to do with the auto-fitler as much as leaving fitlers on.

By Trent L. Taylor - 5/29/2008

Since I am using a maintenance form, does my parent business object have to have the IncludeInFormNavigate property set to true in order to coordinate movement?

If you are using a ListVIew (StrataFrame ListView), then you can just set the AutoNavigateToSelectedRecord property to True and set the BusinessObject property to the child BO...then you don't have to worry about the IncludeInForm navigate stuff at all....it is much easier this way.

You will have to be using the 1.6.6 beta to have this new feature.  You can get it here: http://forum.strataframe.net/FindPost16061.aspx

By Douglas Riley - 5/29/2008

Thanks again Trent!
By Trent L. Taylor - 5/29/2008

Sure Smile
By Edhy Rijo - 5/29/2008

Trent L. Taylor (05/29/2008)
I'll elaborate more on this in class and show what happens when you leave filters on.  Bottom line, if it is working for you, just leave it alone.

Thanks Trent,

I have a couple of questions for the class already and includes the sorting chapter. Tongue