View Full Version : Multiple comboboxes - data from single remote store - unique values

26 May 2016, 3:08 PM

I'm new to extjs. I managed to use remote store with json data for my combo boxes, but options of them were not unique. I also don't know how to filter the data of the combo boxes separately, since filtering is a property of the store.

Suppose, I have a remote store with json data:

[{ "year" : 2016, "month" : 1, "day" : 1 },
{ "year" : 2016, "month" : 1, "day" : 2 },
{ "year" : 2016, "month" : 2, "day" : 1 },
{ "year" : 2016, "month" : 2, "day" : 3 }]

I would like to show 3 comboboxes, with year, month and day, respectively.
The user should see only 2016 in as option the first, (1, 2) in the second and (1, 2, 3) in the third.

When the user selects value 1 in the 2nd combobox, the 3rd should show only (1,2) options.

Combo boxes should always show unique options. For example the 1st should show 2016 once.

I thought I needed to create 3 stores with the data of the current store, duplicates removed, but I was not sure. So I would like to get some guidance.

The provided JSON data is just to get the idea. I need to handle real business data this way.
The data could be selected with 3 ajax request but I thought it's faster and cheaper to do it once and process on client side.

Could you please tell me what is the simplest way to achieve my goal? Ideas, theoretic advice are welcome as well as code.

Thank you.

27 May 2016, 3:45 AM
You can use store.collect() to get unique values for each of the properties then create 3 different stores for each of the combo. Take a look: