Reputation: 91
I'm looking to dynamically populate a dojo combobox with values that come from a json rest api. Ideally, the user inputs their string into the combo box, a 'get' call is made returning related strings, and the select options are populated with these results.
The JsonRest store seems like a good way to go about doing this, but so far my attempts have been unsuccessful. I am encountering two issues:
My rest api returns a list of strings, while the combo button is expecting a list of objects with specified keys to use as the names/values. I don't have access to the api so I can't change the response structure. -Fixed
The 'get' calls that the json rest store is making is adding an asterisk on to the end of the query, which isn't desirable. -Fixed
My setup looks like this:
this.testStore = new JsonRestStore({
target: "myUrl",
allowNoTrailingSlash: true
});
this.dapComboBox.set('store', this.testStore);
this.dapComboBox.set('searchAttr', 'tag');
I've figured out the asterisk issue, it was fixed by setting the combo box's 'queryExpr' attribute to '${0}'
I solved the unusable list issue by creating my own basic store with get, getIdentity, and query functions. In my new query function I returned a new deferred object. I processed the returned values from the get request to fit the proper format and resolved this new list with my new deferred.
Upvotes: 3
Views: 702
Reputation: 91
Issue 1: Fixed by setting the combo box's 'queryExpr' attribute to '${0}'
Issue 2: Created my own basic store with get, getIdentity, and query functions to fix. In my new query function I returned a new deferred object. I processed the returned values from the get request to fit the proper format and resolved this new list with my new deferred.
Upvotes: 0