Ger Cannoll
|
|
Group: StrataFrame Users
Posts: 430,
Visits: 507
|
I'm trying to set up a Child Form.I 've set up the Parent and Child Business Objects. I've dropped both on a SF Maintenece form. I've set up a PageFrame , one of the tabs is the Child Form. I have dropped a BusinessBindingSource on the form and set its datasource as the child bus object. I have also set the ParentBusinessObject of the childbuiness object on the form.I am displaying all fields in the child. As I naviagte through the patrent, I would expect to see the childdren in the grid, as the parent is navigated to...but nothing is appearing in the child grid. Should this behaviour be automatic, or is there someting I need to do to 'GET'the children into the grid ?
|
|
|
Guillermo Vilas
|
|
Group: StrataFrame Users
Posts: 112,
Visits: 2.3K
|
Hello Gerard It is always useful going through the SF samples provided, the way it works for me is adding this to the navigated event of the primary BO
Private Sub Orders_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles Orders.Navigated
If Orders.Count > 0 Then
Me.OrderItems.FillByParentPrimaryKey(Me.Orders.pk)
End If
End Sub
I hope this helps
------------------------------------------------------------------------ I would like to change the world, but they don´t give me the source code. MS Windows 7 Ultimate 64-Bit Intel(R) Core(TM)2 Quad CPU Q9300 2.50 GHz 6.00 GB of RAM, NVIDIA GeForce 9800 GT MacBook Pro i5 OSX Lion
|
|
|
Ger Cannoll
|
|
Group: StrataFrame Users
Posts: 430,
Visits: 507
|
Hi Guillermo. I have inserted code: ChildBO.FillByPrimaryKey(ParentBO.PrimaryKeyField); in the Navigating event of the Parent BO but still nothing happenning on the child grid. My Parent Primary Key is not the key into the child..another field on the Parent Table acts as the key....dont know if this matters ?
|
|
|
Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
Gerard O Carroll (06/09/2008)
My Parent Primary Key is not the key into the child..another fieldon the Parent Table acts as the key....dont knowif this matters ?Hi Gerard, Yes it does matter, since the FillByPrimaryKey will identify the defined PrimaryKey field(s) in the parent. I believe you will have to create your own FillBy method in the child BO and use that instead.
Edhy Rijo
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
Edhy is correct. You will just need to create your own Fill method to load the records that you need based on the specified parent record. So just create a Fill method on the child BO and call that Fill method on the Navigated event.
|
|
|
Ger Cannoll
|
|
Group: StrataFrame Users
Posts: 430,
Visits: 507
|
Some sample code would be appreciated as I am unclear as to what a '"Fill" method is or what code to put in it To recap, My Parent Business Object has a Pk feld(Primary Key) as well as a ParentStkref Field which links to the Child Table (The linked field in the Child table is say ChildStkref)
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
Below would be an example of a Fill method Public Sub FillMyBO(ByVal ParentValue As Integer) '-- Establish Locals Dim cmd As New SqlCommand("SELECT * FROM MyTable WHERE myParentField = @parentFieldValue") '-- Create the parms cmd.Parameters.AddWithValue("@parentFieldValue", ParentValue).SqlDbType = SqlDbType.Int '-- Fill the BO Me.FillDataTable(cmd) End Sub
|
|
|
Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
Trent L. Taylor (06/09/2008) Edhy is correct. You will just need to create your own Fill method to load the records that you need based on the specified parent record. So just create a Fill method on the child BO and call that Fill method on the Navigated event.Hi Gerard, Here is a code I use in a child BO:
Public Sub FillByPolicy(ByVal FK_Policy As Integer)
Using cmd As New SqlCommand()
cmd.CommandText = String.Format("SELECT * FROM {0} WHERE FK_Policy={1} ", Me.TableName, FK_Policy)
Me.FillDataTable(cmd)
End Using
End Sub
After creating this method, compile your BO library or your solution then use that method instead of the FillByParentPrimaryKey().
Edhy Rijo
|
|
|
Ger Cannoll
|
|
Group: StrataFrame Users
Posts: 430,
Visits: 507
|
I have set up a Separate Fill method but am getting an error. In trying to find out the reason for the error, I have put a Messagebox in the Navigating event of the parent business object as MessageBox.Show(ParentBO.Stref) . I get a --> Current Row could not be evaluated because the current row index is out of range..record count is the last record in the business object...the error is coming from the Get for this field ..loValue=This.CurrentRow["stref"] in the framewrok code. If I take out the MessageBox, I can scroll up and down the parent business object without any errors. My Messagebox is just trying to display a field on the table ....but it seems to be going to EOF for some rason... I dont have any orhte code in there except this.
|
|
|
Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
Hi Gerard, At this point it is better if you post the exact message you are having along with the complete code so we can take a look and see where you may be missing the point. Also for testing instead of Navigating event use the Navigated and make sure your use the ParentBO.Count>0 as pointed by Guillermo.
Edhy Rijo
|
|
|