Skip to content

Commit 43cd1b7

Browse files
author
Dmitry Kuzin (DevExpress)
committed
Work for #240: Add 'config' property for text question with autocomplete
1 parent 4dd536a commit 43cd1b7

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

src/easy-autocomplete.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ function init(Survey, $) {
2727
category: "choicesByUrl",
2828
categoryIndex: 2,
2929
});
30+
Survey.JsonObject.metaData.addProperty("text", {
31+
name: "config",
32+
category: "general",
33+
default: null,
34+
});
3035
Array.prototype.push.apply(
3136
Survey.matrixDropdownColumnTypes.text.properties,
3237
["choices", "choicesOrder", "choicesByUrl", "otherText"]
@@ -49,21 +54,32 @@ function init(Survey, $) {
4954
if (!!questionRootClasses && !!questionRoot) {
5055
questionRoot.style.overflow = "visible";
5156
}
52-
var options = {
53-
data: (question.choices || []).map(function (item) {
54-
return item.text;
55-
}),
56-
adjustWidth: false,
57-
list: {
57+
58+
var config = question.config;
59+
var options =
60+
config && typeof config == "string" ? JSON.parse(config) : config;
61+
if (!options) options = {};
62+
63+
options.data = (question.choices || []).map(function (item) {
64+
return item.text;
65+
});
66+
if (options.adjustWidth === undefined) {
67+
options.adjustWidth = false;
68+
}
69+
if (!options.list) {
70+
options.list = {
5871
sort: {
5972
enabled: true,
6073
},
6174
match: {
6275
enabled: true,
6376
},
64-
},
65-
placeholder: question.placeholder,
66-
};
77+
};
78+
}
79+
if (!options.placeholder) {
80+
options.placeholder = question.placeholder;
81+
}
82+
6783
if (!!question.choicesByUrl) {
6884
options.url = function (phrase) {
6985
return question.choicesByUrl.url;

0 commit comments

Comments
 (0)