Jiri Brazda
|
|
Group: StrataFrame Users
Posts: 78,
Visits: 356
|
Hi, I have 3 or more cascaded objects - for example: Country (CountryID and CountryName columns), Town (TownID, TownName and CountryID columns) and Street (StreetID, StreetName and TownID columns) - just for illustration, I'm not using objects for towns and streets . There is 1:N relationship between Country and Town (through CountryID column) and 1:N relationship between Town and Street (through TownID column). Now I want to use StrataFrame standard windows form for adding and editing of Street object. It works fine with Street object as a primary object. I can even use combo for selecting town. But I would like to use another combo that would be used for selecting country and based on selected country the combo with towns filtered - however I do not know how to do it since there is no direct relationship between Country and Street objects. Is there any possibility to make it? Thanks a lot Jiri Brazda
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
Is there any possibility to make it? Sure. This is something that we do all of the time. Probably a good example would be when you choose a country from our website, the provinces automatically load for that region. We use this logic in our medical application as well. If you have absolutely no relationship or tie between the two tables, then SF or no SF...it is going to be difficult to know how to populate the combo...so on that point I was a bit confused. But taking our countries / provinces example, we do not populate the provinces until a country is selected. So the countries combo populates using the BusinessObject method and the PopulationDataSourceSettings on the FormLoad. When the SelectedValue (or SelectedIndex) changes on the country, it then calls the cboProvinces.Requery() which uses the country to populate only those provinces that belong to the country. Hope that helps.
|
|
|
Jiri Brazda
|
|
Group: StrataFrame Users
Posts: 78,
Visits: 356
|
Hi Trent, the substance of the problem is not in the country combo - I can use another example - e.g. cascade of: - Company - 1:N - Organization Unit - 1:N - Worker - Forest - 1:N - Tree - 1:N - Limb - 1:N - Leaf Let's say that we have the last mentioned example. Now I have a StrataFrame maintenance windows form that has BOLimb set as its PrimaryBusinessObject. Since the object itself has properties LimbID (Unique ID of Limb), LimbName (text) and TreeID (Unique ID of Tree), I can manage the relationship between Tree and Limb with combo. But my problem is that first of all I would like to make a choice of the forest that the Tree belongs to - however I do not know how to do it on Limb form, since there is no direct relationship between forest and limb but cascaded relation ship through the tree object (Tree object has TreeID unique identifier, TreeName and ForestID properties). Of course that I can allow to choice from all Trees disregarding of the Forest that it belongs to but since there could be a lot of trees across all forests it seems to me useful to filter trees by forest at first level. I note that I have set parent relationships on appropriate objects. I hope I have described my problem more closely. Thank You Jiri
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
I'm sorry, Jiri, I am really not following this. First, the PrimaryBusinessObject really doesn't matter in most cases. If you use the default settings of a MaintenanceFormToolstrip and IncludeInForm... settings, then it would be the BO that has a new record created, etc. when you click the New button, but past that, it doesn't matter. Secondly, I guess I don't understand why you wouldn't just use the ChildFormDialog (as from what you are telling me you are calling a child form) and then use the translations to translate all of the BOs that you may need on the child form. So I guess I am really not getting your point, sorry If you could provide a sample showing your problem maybe that would be a better way to go at it.
|
|
|
Jiri Brazda
|
|
Group: StrataFrame Users
Posts: 78,
Visits: 356
|
Hi Trent, I'm going to describe all forms used in application (based on example with forest - tree - limb...). First maintenance form - Forest: - primary business object is set to Forest and one textbox (ForestName) is included - this form works fine Second maintenance form - Tree: - primary business object is set to Tree - contains one textbox (TreeName) and one combo (with PopulationType set to BusinessObject and PopulationDataSourceSettings set to method that select all forests) - this form works fine too Third maintenance form - Limb: - PrimaryBusinessObject is set to Limb - contains one textbox (LimbName) and one combo (with PopulationType set to BusinessObject and PopulationDataSourceSettings set to method that select all trees) - this form works fine - until I try to modify as described below. Now I want to modify the third form to include one more combo that will allow user to choice the forest and after that filter records in combo with Trees (so it contain only trees from selected forest). However I do not know, how to do it - I tried all of the following: - include business objects Forest and Tree to the form and set ParentBusinessObject property approprietaly - set IncludeInFormEditType to AllBusinessObject or DetermineByBusinessObject - change the PopulationDataSourceSettings method of Tree combo to FillByParent But nothing has worked - several errors has been produced :-( I'm new to StrataFrame so may be that my approach is not good but I do not know any better way. Jiri
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
What is the real-world application of this kind of data principle? You are saying that the child record has the ability to change grandparent record. In your illustration, the limb tells the tree what forest it should belong to. That seems a bit confusing. If we go back to the initial illustration of country-->town--street, then the street will tell the town what country it is in. I know that I may be oversimplifying, but it does not seem like this kind of cascading relationship is what you are looking for. The limb shouldn't care what forest it is in. The street shouldn't really be concerned what country it is in. These are not directed relationships, but rather derivative. Perhaps a little more clarity on the actual usage would help here. The illustrations may be getting in the way. Bill
|
|
|
Jiri Brazda
|
|
Group: StrataFrame Users
Posts: 78,
Visits: 356
|
The real world application is very difficult to describe here. However - I have probably not defined clearly what I really need. Let's discuss the first example. Imagine that You are in form where You are editing streets in towns. So You would like to add new street. You can type the street name and select relevant town from combo. It works fine since the street object has child relationship with the parent object Town. That ok so far. But imagine the situation that there are thousands towns from different countries. Then it would be a good idea to allow user to select the country (by combo or whatever else) and based on selected country to fill combo with towns only from this country. But I do not know how to do it when there is no relationship between street and country (but as I have mentioned before there are two parent - child relationships - Country-->Town and Town-->Street). So combo with countries would be used only for filtering data but the information about Country will not be saved since the information about town holds this information.
|
|
|
Bill Cunnien
|
|
Group: Forum Members
Posts: 785,
Visits: 3.6K
|
Ok...maybe I am getting it (my skull is much thicker than the average person). You are looking to filter the town list based on a selected country on the street form. I would add a data retrieval method to the TownBO...something like FillByCountry(int pCountryIndex). Then I would fill the town combobox with that method on your street maintenance form. Provide a combo box that displays available countries. When a user changes countries, simply requery the combobox with the selected country index. This will provide a list of towns just for that country. The town combo would be bound to the StreetBO's foreign key. When navigating the street records (StreetBO navigated event), you could easily grab the TownBO from the selected item in the combobox, retrieve the country index then set the country selected index to reflect the selected town in the StreetBO. Wow! I hope that makes sense. Sorry that I don't have code samples...kinda in between a couple of things here...let me know if you need more info. Bill
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
I guess my confusion here is that I see a relationship. Why can't you just create an INNER JOIN query that allows the countries to filter the towns based on the streets (or any combination therein). Unless I am totally missing you here, let's just forget which form you are on. You said that you have a relationship like this: Countries -> Towns -> Streets If this is the case, then regardless of where you are, you can filter any combination based on the country. For example let's assume that I have the following structure: Countries ct_pk - INT - Primary Key ct_Name - VARCHAR(128) Towns tw_pk - INT - Primary Key tw_ct_pk - INT - Foreign Key of Countries tw_Name - VARCHAR(128) - Name of town Streets st_pk - INT - Primary Key st_tw_pk - INT - Foreign Key of Towns st_Name - VARCHAR(128) - Name of street OK, I know that this is a simple structure example, but I am not getting your problem, so let's just take this structure sample. In the case that all I have is the countries and I want to get the streets based on the selected country, I would create a query something like this: SELECT Streets.* FROM Streets, Towns, Countries WHERE Streets.st_tw_pk = Towns.tw_pk AND Towns.tw_ct_pk = Countries.ct_pk AND Countries.ct_pk = MySelectedCountryValue In the above query, I would just be passing over the MySelectedCountryValue as an INT of the selected country from the combo. I am not sure if I am in the ballpark here of your problem, but there is generally always some type of relationship that you can use to get back to the data, so I guess that is my point of confusion in your problem here.
|
|
|
Greg McGuffey
|
|
Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
Jiri, To add to what Bill and Trent both said, I think on the limb form you need: - combo that allows user to choose the forest. This is an unbound combo...they are just using it to filter the list of available trees. It uses population list settings that hit a fill method of the Forest BO, but the Forest BO isn't needed on the form at all. Likely you'll set the SelectedValue to the ID of the forest. Then setup an event handler on the SelectedIndexChanged, and requery the Tree combo. - combo that allows user to choose the tree. This is bound, as it represents the parent of the limb. This uses population list settings that use a Fill method on the Tree BO that requires a Forest ID as a filter. As such, you'll need to have a ListPopulating event handler that sets this parameter from the SelectedValue of the forest combo above. Now, you might need to handle a couple of other situations: - When a record is navigated, you'll likely need to select the forest associated with the tree, so the user isn't confused/can easily change the tree within the same forest. Lots of ways to do this, but you might consider a custom field property on the limb BO. You could either look it up every time (most direct, easiest to understand/do) or you could include the field in the Fill method. Lots of options here and strictly speaking, not on topic - If there is an existing tree set and then the user changes the forest, you'll need to clear the tree, as it won't match the forest anymore. I'd try just clearing the tree combo before requerying it in the SelectedIndexChanged event handler of the forest combo. Hope that makes sense and is what you are looking for.
|
|
|