Issue using JQuery to access hyperlink in Angular grid
We are on TC Version 12.2 and I am trying to use JQuery to access a hyperlink (9936) in the cost center column within an Angular grid. I have found that all of the data in the grid (headers, all data lines, footer with page numbers) are contained in one object thus I am not able to search for data within the grid. Our development team indicated that we need to use JQuery to access the grid data per the following:
var link = $("a.costCenterLink").filter(function(){ return $(this).text().toLowerCase() === '9936';});
The variable “link” now contains the <a> element with a correct cost center link.
Then you can simulate browser click event by:
link.trigger(“click”);
When I tried the above two lines I received a JavaScript runtime error on the var link line:
ReferenceError
$ is not defined
So I added page.contentDocument.Script into that line per an example found in TC help and I was able to execute the code without error. However nothing happens in the test – the cursor does not try to select the cost center in the grid.
Here is the code:
//select item in grid
Log.Message("before var link line");
var link = page.contentDocument.Script.$("a.costCenterLink").filter(function(){ return $(this).text().toLowerCase() === '9936';});
Log.Message("before click");
Log.Message(link);
link.trigger("click");
Log.Message("after click");
Attached is what shows in the log, which is basically all of my comments. But nothing happens in the actual script.
Need some help understanding how to get this to work.