I want to implement dependent dropdown feature on a web page in my website containing the following drop-downs:
1. User's group name
2. Group events (dependent drop-down)
3. Locations (dependent drop-down)
Now, what I want is according to the selected option in the first drop-down that is group name( the other two will be disabled until it is selected), the list of events is displayed; only those values relevant to the selected group name should occur. Similarly, the values of locations should be in relevance to the group name and the event selected. Not only this, but I also want the design to be irrelevant of the level of dependencies or the current order (group name->events->locations). Even if I wish to add timings as another level of dependency, the design should incorporate it.
Now, in all the related questions to this problem tables are used to store data in databases like:
two dependent drop down list with the values in two different table Yii dependent Dropdown But, I wish considering the following alternatives:
1. Trie: Since the order in which the attributes are selected is defined, we could use a trie to store all possible combinations of the list of values in each dropdown dependent on each other. Using prefix search, we could retrieve the values of the next dropdown, according to value selected in the previous one.
2. Table: similar to one used in above, we can store it in database but then the number of levels of dependencies are not really fixed and can increase in future. How do I handle that? (Assuming I dont want to modify the schema every time this happens)
3. Graph: We could also store the possible combinations in a directed graph and based on the values selected we can display all the next adjacent nodes int he next dependent dropdown.
Which of these is a best approach keeping in mind future extensibility or changes? Or any other suggestions for data structures are also welcomed. Please explain with proper design in detail considering complexity in mind. Please reply asap.
Aucun commentaire:
Enregistrer un commentaire