I've got an instance of Typeahead pulling in a remote JSON object that lists airports, and I need to group them in the suggestions by 'location groups', as in the image below:
...and here's an example of how the JSON is formatted:
{
"locations":[
{
"name":"London Intl Apt (YXU), Middlesex, Ontario, Canada",
"type":"airport",
"id":"528cc236e4b0ec1df53b21af",
"iata":"YXU",
"locationGroup":"",
"locationGroupName":""
},
{
"name":"London - Gatwick Apt (LGW), West Sussex, England, United Kingdom",
"type":"airport",
"id":"528cc236e4b0ec1df53b28cb",
"iata":"LGW",
"locationGroup":"LON",
"locationGroupName":"London - All Airports (LON)"
},
{
"name":"London - Heathrow Apt (LHR), Greater London, England, United Kingdom",
"type":"airport",
"id":"528cc236e4b0ec1df53b28b1",
"iata":"LHR",
"locationGroup":"LON",
"locationGroupName":"London - All Airports (LON)"
}
]
}
So where an item has a 'locationGroup' value it should be grouped with all other items with the same 'locationGroup'. If there is no 'locationGroup' it should just be listed individually.
I'm guessing that (assuming this is possible) this should be done when I'm setting up the Bloodhound engine - possibly within the Filter - but I'm really struggling to work out how. Can anybody help with this?