Is there a way to get a row from the list filtered by SetFilterRowCell? When I filtered the list with SetFilterRowCell, the filtered list still maintain the same row index before the filtering. So, I would have to know the row index before the filter to select the row. For example, the row may have index of 201. I expect after the filtering the row index should be 0 since it becomes the first row after the filter is applied....however, i will still need to use row index 201 to select it. Is there a way to select it using the row index 0 as it appeared in the new filter list?
You can select a row based on the visible index by looping through the rows and checking the IsFilteredOut property of each row. When you have found the nth row, use the actual index to select that row. For example the following code will activate and select the fifth row when a filter is applied to a grid:
currentIndex = 0 For i = 0 to swfwindow("Form1").SwfTable("ultraGrid1").GetNAProperty("Rows.Count") - 1 If swfwindow("Form1").SwfTable("ultraGrid1").GetNAProperty("Rows["+ cstr(i) +"].IsFilteredOut") = false Then currentIndex = currentIndex + 1 If currentIndex = 5 Then swfWindow("Form1").SwfTable("ultraGrid1").ActivateRow CStr(i) swfWindow("Form1").SwfTable("ultraGrid1").SelectRow CStr(i) End If End If Next
Let me know if you have any questions with this matter.
The issue is that my table has thousands of rows. It takes minutes to loop through all rows. That is the reason why I tried to filtered the table first to a smaller list, but unfortunately i can't get the row from the smaller list...
There is a method exposed off the Rows collection that returns a array of UltraGridRow objects. You can access this with the following in QTP:
SET grid = SwfWindow("Form1").SwfTable("ultraGrid1").ObjectfRows = grid.Rows.GetFilteredInNonGroupByRows()
Beyond getting the count using Ubound(fRows), I am not sure of any way to get anything useful from this Array. If you try to access an item using fRows(0) you will get a Type mismatch error.
This is good stuff. Is there a way to get the row index # of the each item in fRows array. Thanks,
I wasn't able to access the items in the Array which should be the UltraGridRow objects. I am not sure why this happens and we also have no control over it as the functionality is provided by QTP and the .NET Add-In. As such this approach is limited.