Hi,
I am using a textbox prompt (Lets call it PromptA) as search prompt using custom control and datasets. Find below the script. It works fine by itself but if I add another textbox prompt (PromptB) its not working as expected. PromptB is showing the same dataset values of PromptA even though I used different query and columns for this dataset. Any suggestions are welcome.
define(function () {
"use strict";
function textboxsearch() {
};
textboxsearch.prototype.draw = function (oControlHost) {
var vPromptName = oControlHost.configuration["Prompt name"];
var vPrompt = oControlHost.page.getControlByName(vPromptName);
var vInput = vPrompt.element.getElementsByTagName("input")[0];
vInput.setAttribute("list", "autoCompleteValues");
var vDatalist = document.createElement("datalist");
vDatalist.id = "autoCompleteValues";
var vDataStore = oControlHost.control.getDataStore();
for (var i=0; i<vDataStore.rowCount; i++) {
var vOption = document.createElement("option");
vOption.setAttribute("value", vDataStore.getCellValue(i,0));
vDatalist.appendChild(vOption);
}
vInput.parentElement.insertBefore(vDatalist, vInput);
};
return textboxsearch;
});
The autoCompleteValues list has a unique ID, so PromptB is still pointing at the list for PromptA.
Try this:
define(function () {
"use strict";
function textboxsearch() {
};
textboxsearch.prototype.draw = function (oControlHost) {
var vPromptName = oControlHost.configuration["Prompt name"];
var vPrompt = oControlHost.page.getControlByName(vPromptName);
var acvID = 'ACV'+oControlHost.generateUniqueID();
var vInput = vPrompt.element.getElementsByTagName("input")[0];
vInput.setAttribute("list", acvID );
var vDatalist = document.createElement("datalist");
vDatalist.id = acvID;
var vDataStore = oControlHost.control.getDataStore();
for (var i=0; i<vDataStore.rowCount; i++) {
var vOption = document.createElement("option");
vOption.setAttribute("value", vDataStore.getCellValue(i,0));
vDatalist.appendChild(vOption);
}
vInput.parentElement.insertBefore(vDatalist, vInput);
};
return textboxsearch;
});
Thanks Paul. I tried your new code and its working. you are the best. Thanks again.