Skip to content

Instantly share code, notes, and snippets.

@timwis
Created December 31, 2015 11:44
Show Gist options
  • Save timwis/7208f3fd147a0e3544d2 to your computer and use it in GitHub Desktop.
Save timwis/7208f3fd147a0e3544d2 to your computer and use it in GitHub Desktop.
KeyValDropdownEditor.prototype.prepare = function () {
Handsontable.editors.BaseEditor.prototype.prepare.apply(this, arguments) // call parent method
var source = this.cellProperties.source
var options
Handsontable.Dom.empty(this.select)
if (typeof source === 'function') {
options = source(this.row, this.col, this.prop)
} else {
options = source
}
// If options is a promise, wait for it to resolve before continuing
options.forEach(function (option) {
var label = option.label || option.value || option
var value = option.value || option.label || option
var optionEl = document.createElement('option')
optionEl.value = value
Handsontable.Dom.fastInnerHTML(optionEl, label)
this.select.appendChild(optionEl)
}, this)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment