Commit aac1e7d7 authored by David Stutz's avatar David Stutz

Merge pull request #281 from conradfr/master

Option groups support for the dataprovider method
parents 7a5590de 7c796575
......@@ -874,10 +874,23 @@
*/
dataprovider: function(dataprovider) {
var optionDOM = "";
var groupCounter = 0;
dataprovider.forEach(function (option) {
optionDOM += '<option value="' + option.value + '">' + option.label + '</option>';
});
if ($.isArray(option.children)) {
groupCounter++;
optionDOM += '<optgroup label="' + (option.title || 'Group ' + groupCounter) + '">';
option.children.forEach(function(subOption) {
optionDOM += '<option value="' + subOption.value + '">' + (subOption.label || subOption.value) + '</option>';
});
optionDOM += '</optgroup>';
} else {
optionDOM += '<option value="' + option.value + '">' + (option.label || option.value) + '</option>';
}
});
this.$select.html(optionDOM);
this.rebuild();
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment