Multiple dropdowns

I am going to have three dropdowns on my form. First one will drive data for second, and second will drive data for third. All three will be pulling data from the server. Without going into technical details what approach should I take? Any samples avaialble for such thing? I have looked into “Dependent Selects” sample but it looks very simplified to my needs.

Hi Mark
Just to clarify: When you modify the value of the first select item, the set of options (pulled from the server) for the second item should change, right? (And similarly selecting a value from the second item should change the set of options available in the third select).

If this is right - how is the set of options in each of these cases to be retrieved from the server? Are they to be taken from different datasources, or just re-filtering the same dataSource with different filter criteria (or something else entirely)?

Also - roughly how many options are being returned from the server in each case? If it’s a small number this may modify the best approach.

Thanks
Isomorphic Software

<Just to clarify: When you modify the value of the first select item, the set of options (pulled from the server) for the second item should change, right? (And similarly selecting a value from the second item should change the set of options available in the third select).
This is correct.

The number of options is small: from 10 to 30.
I can use same DS with a parameter to indicate which box is asking for data.
Then the server will decide how to provide the data.
The set of options is retrieved via same asp page.

Ok - a couple of options:

Since it’s a relatively small set of data, you can call dataSource.fetchData(…) to retrieve the set of options as an array of record objects, then you can convert this to a valueMap object (either an array of valid strings or an object of string mappings to data values), and apply the valueMap to the select items by calling ‘setValueMap()’.

Alternatively, if all the options are coming from the same dataSource, you can have the options be retrieved automatically by setting the optionDataSource property on your select items (and setting displayField and valueField, if necessary).
If you take this approach and you need each select to be able to show more than one set of options (depending on the values of the other select items), you can override getPickListFilterCriteria() to return the criteria you want to send to the server. This method will be called each time the list is re-shown, so you’d put in logic to check (for example) the current values of the other select item[s] on the page).

Regards

Isomorphic Software

I have form’s item described like this:

{name: "division", title: "Divisions", type: "select", endRow: true, valueField: "division_id", displayField: "name",
         colSpan:2, optionDataSource:"Divisions", changed:"Subdivisions.fetchData({division_id:form.getValue(this.name)})"
        },

…
I am checking server and it is getting correct filter. Query runs then and creates data but the combo that has Subdivisions as a dataSource is not refreshed with new data. What else do I need to do?

Hi Mark
It looks like in this case you have 2 selects - one with code shown in your last entry, and another whos optionDataSource is set to “Subdivisions”, right?

Ok - so rather than calling ‘fetchData()’ on the Subdivisions dataSource in response to “changed” on the divisions selectItem, implement a ‘getPickListFilterCriteria()’ method on the second selectItem that will always look at the value of the first select item. Then when the user shows the set of options in the second select item, you should see a new filter occur to retrieve the set of options, based on the criteria returned by getPickListFilterCriteria().

Make sense?

How am I implementing getPickListFilterCriteria()?

Just override the method on your second SelectItem to return criteria based on the current value of your first SelectItem.

Something like this:

getPickListFilterCriteria : function () {
    return {division_id:myForm.getValue("division")};
}

Looks like it’s working except when a page is loaded and a first combo has its value populated from a database second combo does not have its selection list properly set. I need to change first combo’s value and change it back to “refresh” second combo.

We’re not entirely clear on what you mean here.
Can you give us more details? What is the expected behavior, and what are you seeing instead?

Thanks

Ok, I have three combos. First combo drives selection for a second one, and the second does it to third.
First scenario: All three combos have no data values being saved and they are shown as empties. Now I am selecting something into first one. Going to second I see that its selections have been filtered on selected value from the first one. Same will be with the third one when I select something in the second. So far so good.
Second scenario: I am selecting data in the first one and then save data. No selections have been made into second and third. I am refreshing my page and I am getting first combo with data being saved. But second combo has its selections unfiltered despite that the first combo has value selected, just like in the first scenario when no selections had been yet made.

Hi Mark
This sounds like it should be working.
Some questions that might help you debug it:

When you refresh the page, what is the value in the first ComboBoxItem? In other words, if you call ‘getValue()’ on that item, what value gets returned?

If you add a log statement to the ‘getPickListFilterCriteria()’ override in the second combobox item, you should see it being run when the user clicks on the second drop down to show it for the first time…
What is the reported value of the first item at that point?

If you can’t make sense of it - put together a standalone example that demonstrates the problem and send it to us and we’ll take a look
Thanks

Isomorphic Software Support

<if you call ‘getValue()’ on that item, what value gets returned?
It returns 18 which is correct ID. Second combo would have been properly filtered on that value if I would enter it.
I need to work on your second idea because I am not sure what you are talking about.