Selecting a row in a webtable

Its been a long time since I have wrote anything in my blog. Well thats because I had to shift job and the new job has been really busy over the past few months. Ok...lets get into business....
A WebTable looks similar to a WinListView object. So we would think that the methods and properties are also going to be the same ... but not really !! The reason is one is a Standard Web Object whereas the other is a standard Windows object. I have been working a lot on the WinListView object but recently I came across a situation where I had to select a row in a WebTable. Well I thought that was too simple... I could just do something like WebTable().Select . Hmm... but thats not possible because we do not have a Select method for WebTable.
So how do we do it ! This is a two step process...
Step 1: Identify a WebElement within each row in the WebTable
Step 2: Click on the WebElement
Now, there might be other ways of doing this but I feel the above method a more simple process.
For Step 1, we need to make use of the ChildItem method. So what does ChildItem method do ?
Syntax:
ChildItem(row, col, object type, index)

ChildItem returns an object from a cell (using its row and column properties) by specifying the type of object we are looking for and also specifying an Index if there are multiple occurrences of that object. Was that a complex statement ? Maybe... Ok..lets take an example...
Lets say there is a WebTable with 4 rows and 4 columns. Now each cell is associated with a row and column and we are looking for a WebElement within each cell. It is possible that there are multiple WebElements within each cell (rare but still possible). The ChildItem method's last argument of Index would help to identify each WebElement within the cell.
Ok...so lets do Step 1
Set objChildItem = ....WebTable("Accounts Table").ChildItem (rownumber, 1, "WebElement", 0)


So what we have done above is identified a WebElement in the row 'rownumber' and column 1. We specified index 0 to pick the first WebElement within this cell if there are more.
Now lets move to step 2
objChildItem.Click

This should select the row.
Now wasn't that simple enough ? I am sure it was.
Hope it helped you or will help you in future.

I dont want to have any sort of copyright or copyleft in this site but if you are reusing this code in any other site, I would appreciate you to provide this page as a link so that others get a more descriptive explanation of this concept. Your suggestion and comments are always welcome. Cheers !!!
As always,
Your friend in need,

George, Reju

Read Users' Comments (0)

Visitors

Website Counter