Ved, your code doesn't really do much. You could set both connections to query on load, rather than on change, and you'd get the same effect without the additional wait time after each change. This is because you are not doing anything in your connection to filter your results. And since you mentioned you have more than one pair of these drop-downs in the view, that's probably the better choice--as filtering the data connection would affect all drop-downs, and not just the one you are currently working on.
So, with both data connections queried for results, the focus goes to the filter you placed on DropDown2.
Let's get a few facts straight here first:
-
You have 2 data connections, which I will call "dcState" and "dcCity"
-
You have 2 nodes in your data sourse, which I will call "nState" and "nCity"
-
You have 2 drop-down controls in your view, which I will call "ddState" (bound to node "nState") and "ddCity" (bound to node "nCity").
-
You want to filter the "ddCity" based on the selected value in "ddState" -- which value is stored in node "nState"
In order to do this, data connection "dcCity" needs to have a State node present in it.
Then, the fitler you add to control "ddCity" needs to specify that the "dcCity/State" is equal the value stored in node "nState".
This is basically stating that you only want to see cities that have an associated state equal to the one selected in the state drop-down.