Stack Exchange
Dojo FilteringSelect SearchAttr search name of attribute of array
I have the following array:
    [{"id":1,"vak":{"naam":"Wiskunde"},"onderwerp":"Dit is het onderwerp van de les ..."},
     {"id":2,"vak":{"naam":"Aardrijkskunde"},"onderwerp":"Bli Bla, Dit is het onderwerp van de les ..."},
     {"id":3,"vak":{"naam":"Biologie"},"onderwerp":"Dit is het onderwerp van de les ..."},
     {"id":4,"vak":{"naam":"Wizkunde"},"onderwerp":"Dit is het onderwerp van de les ..."}]

I want to implement a filteringSelect that searches for "naam".
When I search for "onderwerp", I just set my searchAttr like this:
    this.lessonsSearchBox.set("searchAttr", "onderwerp");

But I don't know how to set my searchAttr if I want to search for "naam", because "naam" is an attribute from "vak".
How can I do this?

As far as I know (and looked at the source code), you can't. It's just using that attribute as the property name.
The best solution I can come up with is by mapping your array, for example by doing the following:
var newRoosterItems = array.map(roosterItems, function(item) {
    var newItem = lang.clone(item);
    lang.mixin(newItem, {
        vakNaam: item.vak.naam
    });
    return newItem;
});

This maps your array to a new array of items and every item will have a property called vakNaam which contains the naam property of your vak.
An example JSFiddle can be found here.

If you don't need the original data, you can also choose to convert the existing data, by using:
array.forEach(roosterItems, function(item) {
    lang.mixin(item, {
        vakNaam: item.vak.naam
    });
});

