아래와 같이 하니 해결이 됩니다.
많은 팁 감사합니다.
- ax5.ui.grid.inlineEditor 에 autocomplete 생성
var GRID = ax5.ui.grid;
ax5.ui.grid.inlineEditor.autocomplete = {
useReturnToSave: false
, editMode: “popup”
, getHtml: function (_root, _columnKey, _editor, _value) {
var po = [];
po.push(’
’);
po.push(’’);
return po.join(’’);
}
, init: function (_root, _columnKey, _editor, _$parent, _value) {
var $el;
_$parent.append($el = jQuery(this.getHtml(_root, _columnKey, _editor, _value)));
this.bindUI(_root, _columnKey, $el, _editor, _$parent, _value);
return $el;
}
, bindUI: function (_root, _columnKey, _$el, _editor, _$parent, _value) {
var eConfig = {
columnKeys: {
optionValue: “value”,
optionText: “text”,
optionSelected: “selected”
}
};
jQuery.extend(true, eConfig, _editor.config);
eConfig.options.forEach(function (n) {
if (n[eConfig.columnKeys.optionValue] == _value) n[eConfig.columnKeys.optionSelected] = true;
});
var self = _root;
_$el.data(“binded-ax5ui”, “ax5autocomplete”);
_$el.ax5autocomplete($.extend(true, {
tabIndex: 1
, direction: “auto”
, removeIcon: ‘
’
, onSearch: function (callBack) {
var searchWord = this.searchWord;
setTimeout(function () {
var regExp = new RegExp(searchWord);
var myOptions = [];
eConfig.options.forEach(function (n) {
if (n.text.match(regExp)) {
myOptions.push({
value: n.value,
text: n.text
})
}
});
callBack({
options: myOptions
});
}, 150);
}
, onStateChanged: function () {
if (this.state == “open”) {
this.self.activeautocompleteOptionGroup.attr(“data-ax5grid-inline-edit-picker”, “autocomplete”);
} else if (this.state == “changeValue”) {
GRID.body.inlineEdit.deActive.call(self, “RETURN”, _columnKey, this.value[0][eConfig.columnKeys.optionValue]);
} else if (this.state == “close”) {
GRID.body.inlineEdit.deActive.call(self, “RETURN”, _columnKey);
}
}
}, _editor.config));
_$el.ax5autocomplete(“setValue”, _value);
_$el.find(“a”).focus();
}
};
- 그리드에 에디터 설정
//옵션 값 맵에 담기
var oblationMap2 = {};
oblation_obj.forEach(function (n) {
oblationMap[n.value] = n.text;
});
{ key: “auto_cd”, label: “라벨”, width: 200 , align:“left”, sortable: true
, formatter: function () {
// 그리드에 value 값 대신 text 값 보이기
return oblationMap2[this.value];
}
, editor: {
type: ‘autocomplete’,
config: {columnKeys: {optionValue: ‘value’, optionText: ‘text’}, options: oblation_obj}
}
}