FX Dependent ListMenu - (by Felice Di Stefano)
This object will create a set of multilevel dependent lists or menus creating all required recordsets to accomplish the task. Multilevel because it is not restricted to a single pair of dropdown lists but it may include a chain of dependences with more than 2 list/menu, in the chain in can be included optionally also a textarea as last element. But this is not all because it may be able to create multiple dependence sets at on time and with no restriction of form dependence. That is, you may create a pair and then another pair at the same time.
Applying
Before opening the object
you must have at least a form on the page and all the required elements empty
and named, it doesn't matter if you have on the form(s) more elements than what
you require. Example, if you intend to create a dependent pair of dropdowns,
you must have at least 2 empty dropdown elements on the page.
Then you can open the FX Dependent ListMenu object from the Insert-->Felixone
Objects menu in the top bar or from the Felixone Objects submenu in the Insert
panel.
| Connection: | Define here the connection to the database which will be used by the created recordsets. |
| Elements: | Here are
listed all valid elements found on the page, only list/menu and textarea
will be listed. First of all check that the elements stay in the right chain order, no matter if on the page the dependent element is before than the master, here you will move down the dependent after the master using the up/down arrows above the list. If you will have a 2 level dependence move the first dependent after the master then the second dependent after the first dependent, taking care that a textarea it must be always the last (this is obvious). Now select an element (we can start from the master) and apply the parameters which are listed below, and so forth you will select another element and apply the parameters. |
| Link to Table: | Select the table to which you want to bind the selected element. When the element is a dependent you must care that there is a relation between the table used for the master or prior dependent and the actual dependent. You may use the same table or a different table, it's important there is always a relation in between. |
| Label Column: | Select here the table column which will display on the list. |
| Group By: | If the Label Column contains repeating items you may check this box so the the item will be grouped and displayed only once. Example you want to list the Make of a products table, since the Make has not to be unique it may be found in different rows. |
| Value Column: | Here you
select the column which will contain the value related to the label column.
Assume that the dependent element will be linked to this. For instance this
column may be an unique ID (not necessarily) and the label a unique description
of the item or just the same ID column. If you are grouping the Label Column it would be very recommended that you use the same column for label and value unless you know what you are doing. Anyway, in most cases, it would be obvious to use the same column for both label and value. |
| Dependence: | Here you
will select the element from who will depend the selected one. If " *** None " is selected the selected element will be ignored and not included in the set. If " - Master - " is selected the selected element will be obviously a master not depending from other elements. If you choose an element (here only the dropdowns will be listed) it means that the selected element will depend from the chosen element. |
| Where Col: | The Where Column correspond to the condition used in the sql query of the recordset used for the dependent element, therefore (WHERE Column = Dependence). To make it more simple for example, in a simple pair where the prior element (of course the Master) has an 'itemID' as value, the Where Col for the dependent selected element will be the 'itemID'. |
| Add Event: | This will
add a javascript onChange event to the element in case you require, that
is, the form will be submitted any time you select an item from the dropdown
list or just select it from a multiline list. If you don't want it because
you want to use a submit button don't check this box. It will never be applied to textareas. |
Once you click OK the required elements will be filled with the appropriate code and all required recordsets will be created. Then you can freely re-edit them or use the recordsets also for other purpose. The recordsets will be named using the related element name prefixed by "fx", if the dropdown element is "mylist" its recordset will be "fxmylist".
An example of multilevel dependence
Assume we have a products
table and all required data is in this table. We want a Master which displays
all the Categories, clicking on one category will display in the second one
all Makes (or producer) available, then selecting a make will display all related
Product ID and at end selecting a Product ID its description will appear on
a textarea. In case we want to display some other data related to the Product
ID, example the price, simply bind the Price column from the recordset was created
for the textarea where you want, on the page or a textfield you include on the
form.
Note: the created recordsets will recall only the
label and value columns if they are grouped, but will recall all data if they
are not grouped, this to leave you the freedom to do what you like with the
recordset. In any case you can always re-edit the recordset appropriately.
Create the form if you don't have one on the page, insert 3 list/menu and a textarea in the form if they do not already exists and name them appropriately. Open the object dialog and define the Connection, then re-order the elements in the list if they are not ordered in a consequent chain (ie: category, make, id, description).
Select one element from
the list, for commodity we start from the master. Look that it is not important
at which moment you set up an element, it is important that the element the
element is listed in the right order and that the settings follow the chain
logic.
Then in the Link to Table field we select the Products table, since the master
will contain the categories (or what else you like to name it) we will assign
the column Category as Label Col or a column which describes the category, it
would be opportune to check Group By, the same category may be reported in many
records.
It would be not a bad thing to assign the same column as the Value Col unless
you have one column which describes the category and one to identify it.
Now let's tell it's hierarchy, this of course will be the master then we will
select " - Master - " from the Dependence field, the Where Col will
be disabled because a master do not depend from any one.
Select the second element, the one which will directly depend from the master, the Make element. The table will be the same (we are assuming all the data is in the same table), in the Label Col select the column in the table which report the make (it can be named Producer for example) and since the same make can be reported in many records we will group it (check Group By). As Value Col we can assign the same column as the label column. From the Dependence we choose the element from which this will depend, in this case the category dropdown element, the Where Col will be activated then think what we assigned as Value to the category element, we will select the column which corresponds to this.
Now follow this logic for the other elements thinking to the element from which the selected one will depend, of course the Product ID element will depend from the Make element and so forth to the last which is the textarea which will display the description related to the item selected in the Product ID element.
You can check the Add Event box when you want if you want the page to submit at the moment the selection is done. Later you can manually remove it from the <select> tag if you don't want it.
Click Ok and everything is ready. If you are not glad and want to display also the price of the product add a textfield on the page then switch to the Bindings panel expand the recordset related to the textarea and drag the price source inside the textfield, in this way you can display any data related to the Product ID.
Hints
You can create more dependent
lists at the same time. Assume 2 simple pairs, each one has a master and a dependent,
insert on the page 4 named list/menu then open the object and check that they
are displayed on the list in the logic order, if not re-order them (in the page
they can be displayed where you like), and proceed as explained above. Of course
in this case you will have 2 masters.
The only restriction is that you must use the same connection otherwise you
can apply it twice, one with one connection and the other one with another connection.
by FELIXONE