While writing automation for TestComplete using javascript, I cam across an object which appeared like a grid in UI as shown above-
You can identify this object as a List and read or update the item value in it. The below code shows how you can read the values of first column “Code” and based on its value update the check box “Update column” and set the drop down value for “Update With column”.
The object is identified some thing like below-
Sys.Process(“XYZ”).WinFormsObject(“MainForm”).WinFormsObject(“XClient”, “”).WinFormsObject(“LUForm”).WinFormsObject(“tabLive”).WinFormsObject(“tpForm”).WinFormsObject(“dvgHF”)
Assign this object to some variable
var q = Sys.Process(“XYZ”).WinFormsObject(“MainForm”).WinFormsObject(“XClient”, “”).WinFormsObject(“LUForm”).WinFormsObject(“tabLive”).WinFormsObject(“tpForm”).WinFormsObject(“dvgHF”)
//get count of items in the list
var w = q.list.count;
//check for each name in Code column
for (i = 0; i < w; i++)
{
name = q.list.item(i).name; //get the name from the application
if (name == “examplename”) // if name matches with the required name provided as input to the script then set the checkbox and value and return from function.
{
q.list.Item(i).Update = true
q.list.Item(i).UpdateWithName = “All_zzz”
return;
}
}
This code mainly helps to find the list items and a way to update the values.