I'm trying to create a drop down menu using DexExpress in jQuery with SharePoint REST API. I get the values from the REST call in the console, but I'm having issues trying to display these values in the actual dropdown. The values that I'm trying to get are in a SharePoint list. Please see my code below:
$(function() {
var formCo = $("#form").dxForm({
formData: formCo,
colCount: 2,
items: [{
{
dataField:"DropdownField",
itemType:"simple",
editorType:"dxSelectBox",
editorOptions: {
items: [
function items(){
$.ajax({
url: url,
type: "GET",
headers: {
"Accept":"application/json;odata=verbose",
"contentType": "application/json;odata=verbose"
},
success:success,
error: error
});
function success(data){
var dataresults = data.d.results;
var jsonString = JSON.stringify(dataresults);
var parsedData= JSON.parse(jsonString);
for(var i = 0; i < parsedData.length; i++){
//Console log displays Name value
console.log(parsedData[i]['Name']);
}
}
function error(){
//console.error();
}
}
]
}
}
}]
})
})