Created
December 31, 2015 11:44
-
-
Save timwis/7208f3fd147a0e3544d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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