Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
I have a BO which I would like to have access to 2 more related BOs. The idea is to have a property in the Parent BO to the ChildBO and in this ChildBO to another Child like this: CustomersBO.OrdersBO.OrderItemsBO.ItemPrice
How can I do that for SF Business Object?
Edhy Rijo
|
|
|
Greg McGuffey
|
|
Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
This would just be a normal property of the BO type. Note that this will work fine in code, but not for binding (at this time...there have been some posts about this very thing). Private _parentBO As MyParentBO
Public Proprety ParentBO() As MyParentBO
Get
Return _parentBO
End Get
Set(value As MyParentBO)
_parentBO = value
End Set
End Property
|
|
|
Paul Chase
|
|
Group: Forum Members
Posts: 414,
Visits: 2.8K
|
Actually you can bind to your child business object's fields you just can't use the type editor to pick the binding field and business object, if you set the binding in code it works. Me.TxtSuperVisor.BindingField = "JBO_Supervisor" Me.TxtSuperVisor.BusinessObject = Me.BoCustomers.JobSiteBusinessObject Paul
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
Hi Edhy, Hi Greg, I have added a custom property to my customer BO just like you outlined. In my application, I have the CustomersBO.SalesOrdersBO being assigned to the BusinessObject property of a BusinessBindingSource. On the CustomersBO.Navigated event, I simply swap out the related BO: OrdersBBS.BusinessObject = customersBO.CustomerOrders; Works like a charm with the DevEx XtraGrid control. To setup the control, I temporarily add a SalesOrdersBO to the form. Assign it to the BBS, then work out how I want the grid to look. After that, I simply remove the SalesOrderBO. I am sure something similar could be done with the next level of BOs, too. This StrataFrame stuff is rather cool!
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
Wow, Paul! While writing my response, you posted something even cooler!! I shall be using that! Bill
|
|
|
Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
Greg McGuffey (06/13/2008)
This would just be a normal property of the BO type. Note that this will work fine in code, but not for binding (at this time...there have been some posts about this very thing). Private _parentBO As MyParentBO Public Proprety ParentBO() As MyParentBO Get Return _parentBO End Get Set(value As MyParentBO) _parentBO = value End Set End Property Hi Greg, Thanks, but one more question, at some point I need to add code to make the ParentBO property in synch with the current record, where and how to do this? I understand that in my Parent BO I will add a property to the ChildBO, but I want it to be in synch with the current selected parent record. Also I don't have plans to use this for binding, just to get access to related child record for some custom functions and methods I will have in the BOs.
Edhy Rijo
|
|
|
Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
Bill Cunnien (06/13/2008)
Hi Edhy, Hi Greg, I have added a custom property to my customer BO just like you outlined. In my application, I have the CustomersBO.SalesOrdersBO being assigned to the BusinessObject property of a BusinessBindingSource. On the CustomersBO.Navigated event, I simply swap out the related BO: OrdersBBS.BusinessObject = customersBO.CustomerOrders; Works like a charm with the DevEx XtraGrid control. To setup the control, I temporarily add a SalesOrdersBO to the form. Assign it to the BBS, then work out how I want the grid to look. After that, I simply remove the SalesOrderBO. I am sure something similar could be done with the next level of BOs, too. This StrataFrame stuff is rather cool! Hi Bill, In your case, how do you make the SalesOrdersBO in synch with the CustomerBO? so when you make a reference to a field in the CustomersBO.SalesOrdersBO.ItemPrice it will give you the price of the current selected CustomerBO record.
Edhy Rijo
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
I am not using a parent-child setup. My custom property in my CustomersBO handles the plumbing: [ Browsable(false), BusinessFieldDisplayInEditor(), Description("Customer Orders"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public SalesOrdersBO CustomerOrders { get { SalesOrdersBO mSalesOrders = new SalesOrdersBO(); mSalesOrders.FillAllOrdersByCustomer(this.CustIndex); return mSalesOrders; } }I've tweaked this whole thing several times. I am sure that I will tweak it again. Always finding new, more efficient ways to use StrataFrame. Bill
|
|
|
Paul Chase
|
|
Group: Forum Members
Posts: 414,
Visits: 2.8K
|
I'm sure there are more ways to do this but 1.) In the parent business objects current data table refilled event, call the child tables fill by parent method. 2.)Either set the auto filter option or filter the record yourself in the parents navigate event. just remember you have filter on it will bite you. Or 1.) Requery the db in the parents navigated event childbo.fillbyparentpk(myparent.pk)
|
|
|
Edhy Rijo
|
|
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
|
Thanks a log guys, I will start playing with the info provided right now.....
Edhy Rijo
|
|
|