PDA

View Full Version : Linked Comboboxes in a Editor Grid



lupin85.luca
27 Nov 2007, 8:30 AM
Hi all.
I ran into a big problem regarding the logic behind the linked comboboxes behaviour.
Here's a little example (American way):

editorGrid with 2 columns: "state" and "city".
State is a combobox loading its data from a db. It's a collection of ID and Value.
City is a combobox related to State. Its data (loaded from a db) is in form of: ID, IDState and Value. But City table is very huge (say 10000+ records).
What I want is a common task: linked the two comboboxes!

Reading many posts I've made a solution:
Load both datastores before render the grid and then use the ds.filter() on State's select handler.
That works, of course.
But it takes to long to retrieve all the data from the City db (10.000+).

~o)
So I thinked another solution.
The server returns the value (not the ID) of the City field in order to populate the grid.
So user views the exact cities value in the grid.
When he/she edits the State combobox, I've attached an event that does a "ds_city.load(params:{IDState=xxx})", so when he/she clicks on the City value I can render a combobox based on the ds_city.
It works correctly.
The issue is that this solution may call the "ds_city.load()" several times if the user edits many records.

So I ask you: which is the best one?
Have you got another solution?
:-/

Thanks

PS: I hope I've explained it clearly. If not, tell me.