-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Description
I couldn't think of a better title, sorry. But the gist of it, I'm using dataprovider to load the dropdown, and I'm trying to use grouping.
data format:
data=[{title:"group1",stuff:{label:"one",value:1},{label:"two",value:2"}},
{title:"group2",stuff:{label:"three",value:3},{label:"four",value:4"}}]jquery's "isarray" returns false on an object. I had to hack your code up:
dataprovider: function(dataprovider) {
var optionDOM = "";
var groupCounter = 0;
var selected="";
$.each(dataprovider, function (index, option) {
if (option['title']!==undefined) {
groupCounter++;
optionDOM += '<optgroup label="' + (option.title || 'Group ' + groupCounter) + '">';
$.each(option['stuff'], function (index, option) {
optionDOM += '<option value="' + option.value +'" >' + (option.label || option.value) + '</option>';
});
optionDOM += '</optgroup>';
}
else {
optionDOM += '<option value="' + option.value +'">' + (option.label || option.value) + '</option>';
}
});Reactions are currently unavailable