bggann
Active Member
I'm using Database Join and Cascading dropdown to select values from a table based on another field value.
A good analog would be having a user pick a state - then pick from a list of cities in the state.
The "source" table for both the databasejoin and the cascading dropdown is the same - in my example the table would be
id | State | City
1 | CO | Denver
2| CO |Rifle
3 | CO| Silt
4 | WY | Casper
5 | WY | Cheyenne
6 | WY | Douglas
In the form being filled out, the databasejoin filed is used to pick the State.
Then that value is used as the "Watch value" in a cascading dropdown to pick the cities from that state.
The problem is that if I use
id [recommended]
for the Value of the database join field and "State" for the Label
what is presented to the users is
Please Select:
CO
CO
CO
WY
WY
WY
That's not nice.
I really just the unique values from the State Column to show up
e.g.
Please Select:
CO
WY
I can achieve that by using "State" as both the Value and Label in my databasejoin element.
When I do that, only the unique states are rendered in the databasejoin element and works in the cascadingdropdown.
But I'm a little leary of that from a database standpoint because it's not unique.
Any problems with doing this?
I can't think of any reason that would cause problems, but is seems I've had problems not using id[recommended] in other databasejoin elements.
Otherwise I have to make a "State" table for the databasejoing and a "State - City" table for the cascading dropdown, but that is duplicative work and they need to be in sync. I could also hard code the States into a "Dropdown" element - but again - extra work and synchronization.
For clarity - I'm not using State and City in my system, that was just an easy example. It is more "Action" and "Task" where the tasks available to the user are related the action. I can anticipate adding more Tasks and Actions - so I don't want to have multiple tables to synchronize.
-bob
A good analog would be having a user pick a state - then pick from a list of cities in the state.
The "source" table for both the databasejoin and the cascading dropdown is the same - in my example the table would be
id | State | City
1 | CO | Denver
2| CO |Rifle
3 | CO| Silt
4 | WY | Casper
5 | WY | Cheyenne
6 | WY | Douglas
In the form being filled out, the databasejoin filed is used to pick the State.
Then that value is used as the "Watch value" in a cascading dropdown to pick the cities from that state.
The problem is that if I use
id [recommended]
for the Value of the database join field and "State" for the Label
what is presented to the users is
Please Select:
CO
CO
CO
WY
WY
WY
That's not nice.
I really just the unique values from the State Column to show up
e.g.
Please Select:
CO
WY
I can achieve that by using "State" as both the Value and Label in my databasejoin element.
When I do that, only the unique states are rendered in the databasejoin element and works in the cascadingdropdown.
But I'm a little leary of that from a database standpoint because it's not unique.
Any problems with doing this?
I can't think of any reason that would cause problems, but is seems I've had problems not using id[recommended] in other databasejoin elements.
Otherwise I have to make a "State" table for the databasejoing and a "State - City" table for the cascading dropdown, but that is duplicative work and they need to be in sync. I could also hard code the States into a "Dropdown" element - but again - extra work and synchronization.
For clarity - I'm not using State and City in my system, that was just an easy example. It is more "Action" and "Task" where the tasks available to the user are related the action. I can anticipate adding more Tasks and Actions - so I don't want to have multiple tables to synchronize.
-bob