function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
fullvaluefullvalue 

Dojo Combobox and picklist

Has anyone used Dojo ComboBox with picklist values from Salesforce?  I have the code to get the picklist values but can't seem to figure out how to have it populate the ComboBox. 
fullvaluefullvalue
Well..I got this to work.  First you have to build an array with value/label pairs.

Code:
for (var b=0; b<oPicklistVals.length; b++) { 
    myArray[b] = new Array(2);
    myArray[b][0] = oPicklistVals[b].value;
    myArray[b][1] = oPicklistVals[b].value;
}

Then this to set the select widget
 
Code:
var mySelect = dojo.widget.byId("status");
mySelect.dataProvider.setData(myArray);

 


Here is the complete code.  I ended up using a Select widget instead of the combobox


Code:
<script type="text/javascript">
try {
dojo.addOnLoad(function (){
var myArray = []; 
var oTable = sforce.connection.describeSObject("Project__c"); 
var oFields = oTable.fields; 
 for( var a = 0; a < oFields.length; a++) { 
 if(oFields[a].name == "Modules_Status__c") { 
   var oPicklistVals = oFields[a].picklistValues; 
   for (var b=0; b<oPicklistVals.length; b++) { 
    myArray[b] = new Array(2);
    myArray[b][0] = oPicklistVals[b].value;
    myArray[b][1] = oPicklistVals[b].value;
 }
     }
  }
var mySelect = dojo.widget.byId("status");
mySelect.dataProvider.setData(myArray);
 });
}
 catch(e) {
 alert(e);
}

</script>    
</head>

<body>
<div><select dojoType='Select' id="status" autoComplete='true' value="default" style='width: 175px;'></select>
</div>