If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Dataset for Prompts using custom control

Started by texdon21, 27 Oct 2021 07:16:41 PM

Previous topic - Next topic

texdon21

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;
});


CognosPaul

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;
});


texdon21

#2
Thanks Paul. I tried your new code and its working. you are the best. Thanks again.