|
StrataFrame Team
|
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
You wouldn't need to put any code there because the navigation buttons on the MaintenanceFormToolstrip call the Navigate() methods on the business object(s), so the Navigated event is already getting raised (which re-filters the children automatically). The reason you have handle events on the parent grid in your scenario is because of the flat list problem... the grid doesn't need to navigate records, so you have to Navigate the business object manually. With the maintenance form toolstrip, and the way the CustomerMaintenance form works, you have to call Navigate to move to another record.
|
|
|
|
|
StarkMike
|
|
|
Group: Forum Members
Posts: 436,
Visits: 944
|
Thanks Ben, I'll look into that. I posted two things in a row. Please look at post 1033. http://forum.strataframe.net/FindPost1033.aspx
|
|
|
|
|
StrataFrame Team
|
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
The error you're getting when trying to insert the child record is because the Titles business object is configured with PrimaryKeyIsAutoIncremented = True, and the primary key can only be auto-incremented for numeric data types. Since the primary key is not an auto-incremented value, you'll need to set the PrimaryKeyIsAutoIncremented property to False and assign a valid PK value for the new child record before saving. Basically, the server cannot assign the PK value, you'll have to assign it on the client side.
|
|
|
|
|
StrataFrame Team
|
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
As for the child grid not being cleared when you select a record that has no child records, put a handler on the TitlesBO.FilterChanged event and within it, put a message box, or a Debug.WriteLine() call within it and print the TitlesBO.Filter value. Basically, I want to make sure the filter is being set whenever you select a record that doesn't have any child records.
|
|
|
|
|
StarkMike
|
|
|
Group: Forum Members
Posts: 436,
Visits: 944
|
As for the child grid not being cleared when you select a record that has no child records, put a handler on the TitlesBO.FilterChanged event and within it, put a message box, or a Debug.WriteLine() call within it and print the TitlesBO.Filter value. Basically, I want to make sure the filter is being set whenever you select a record that doesn't have any child records. I'll try that. Another question. I have the Customer Maintenance form and I have a parent child relationship setup with the Orders table. There is a grid on the maintenance form that displays the customers orders. I have everything setup correctly (i think) and when i run the program there is no errors but the navigation buttons are disabled. The first customer doesnt have any related orders. I dont know if that has anything to do with it.
|
|
|
|
|
StrataFrame Team
|
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
Make sure that the IncludeInFormNavigateType property on the CustomerMaintenance form is set to PrimaryBusinessObject and make sure that CustomersBO1 is set as the PrimaryBusinessObject on the form. For some reason, it looks like your form thinks it's supposed to be navigating Orders instead of Customers.
|
|
|
|
|
StarkMike
|
|
|
Group: Forum Members
Posts: 436,
Visits: 944
|
I've checked both those things and they were set properly. I turned the ChildAutofilter property off and ran the program and it worked fine. I was able to navigate the customer form and the all the orders filled the grid. When I set ChildAutoFilter to MatchCurrentRow I got the attaced error.
|
|
|
|
|
StrataFrame Team
|
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
I believe that there is already code within the Navigate method on that form that's requerying the database for the orders. You can either requery like that form is doing, or you can fill the parent and child with all of the necessary records and then let the child filtering do its thing. But, if you try to use both methods, you're going to run into problems.
|
|
|
|
|
StarkMike
|
|
|
Group: Forum Members
Posts: 436,
Visits: 944
|
Sorry, I dont understand. I have the SQL statements in the business objects that will be used to fill them. Then in the form I call those Fill methods in each BO's ParentFormLoading Event. You're saying not to fill the BO's on load? This thread seems like its taking on a life of its own.
|
|
|
|
|
StrataFrame Team
|
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
Yes, this thread seems to be more of a chat window  Basically, there are two methods you can use to accomplish what you're trying to do: 1) Fill both business objects in their respective ParentFormLoading events. Use the relationship and the ChildAutoFilterOption to let the parent business object filter the children. This is the option you want to use to reduce network traffic and requeries against the database. However, if you have several thousand child records, this wouldn't be the option you would want to use. 2) Fill just the parent business object in its ParentFormLoading event. Then, in its Navigated event, fill the child business object will only the records that belong to the current parent, say, using the FillByParentPrimaryKey() method on the child business object and passing it the current pk of the parent. This is the method you want to use if you don't care about network traffic or you have several thousand child records, since you don't have to bring them across all at the same time. Method #2 is the method that the tutorial is using, while Method #1 is the way you're sample is handling the issue. Both are correct, and both have their uses, but you can't mix them because it could cause problems with the order that the filter is being set and the child is being filled.
|
|
|
|