Hi Mark,
I have made a custom control that looks at HTML Items with spans that use dataItem values in the attributes and in the draw() method/function that is where I do the DOM manipulation. You can create a unique id for each row in the HTML item span but use a prefix like data-id= cc_+ '+[Data Item1]+'" to find it. You could use a dataset but I think it is easier to just use spans. The advantage of a dataset is being able to access more than what is rendered on the page. You have to scan for more spans each time you paginate and the draw method is run on each re-render. a dataset could potentially make some of this easier by getting the entire dataset at once. I think it is faster just scan the DOM and update it as you paginate.
Each time you paginate each page or "tab" is rendered into a new div with the class "clsViewerPage" and the style of the current page is display: block and hidden pages are display:none;
This means on new page renders the draw function is called and new div is added to the DOM with your visible page. Just search the DOM for your spans in the visible divs for the current page and you should be good to go!
For example my HTML Item report expression:
'<span
data-id = "cc_'+[Gender]+'"
/>'
and the custom control would like this:\
define(() => {
"use strict";
class Control{
initialize(oControlHost, fnDoneInitializing) {
fnDoneInitializing();
}
draw(oControlHost) {
let spanNodeList = document.querySelectorAll('span[data-id^="cc_"]');
console.log(spanNodeList)
}
}
return Control;
});
I use this method to iterate through lists on a page and it works from 11.1.7 to 12.0.4 in interactive mode.
------------------------------
Michael Webb
------------------------------
Original Message:
Sent: Fri April 11, 2025 04:11 AM
From: Marc Reed
Subject: Custom control and accessing a data value
Hi all, (I apologise for the amount of posts I have put up recently!)
I am looking for the technique in how you pass a data item value into a custom control. None of the sample custom controls seem to show this technique.
In C10/Classic Viewer I would build up a HTML item using a report expression similar to:

I could easily reference the list row data item and pass it into a javascript function. In effect setting a prompt by clicking a data item in the list.
I am scratching my head trying to figure out how to do this in CA custom controls.
( Custom controls have datasets. But i don't think this is the right answer - I wouldn't want to run an additional dataset query for every row in the list).
Better still - if anyone has a Cognos Analytics example of using the promptAPI with a custom control to set a prompt value by clicking on a row in a lost. A big ask, but you never know...
Thanks.
------------------------------
Marc Reed
Reporting Lead
------------------------------