Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
jQuery Autocomplete editor for SlickGrid js table
function AutoCompleteEditor(args) {
var $input;
var defaultValue;
var scope = this;
var calendarOpen = false;
this.init = function () {
$input = $("<INPUT type=text class='editor-text' />");
$input.appendTo(args.container);
if(args.column.values){
availableOptions = args.column.values;
}else{
availableOptions = '';
}
$input.focus().select();
$input.autocomplete({
source: availableOptions
});
};
this.destroy = function () {
$input.autocomplete("destroy");
};
this.focus = function () {
$input.focus();
};
this.loadValue = function (item) {
defaultValue = item[args.column.field];
$input.val(defaultValue);
$input[0].defaultValue = defaultValue;
$input.select();
};
this.serializeValue = function () {
return $input.val();
};
this.applyValue = function (item, state) {
item.autocompleted_value = state;
item[args.column.field] = state;
};
this.isValueChanged = function () {
return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue);
};
this.validate = function () {
return {
valid: true,
msg: null
};
};
this.init();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment