Searching for Records in Infragistics UltraWebGrid

Applies to TestComplete 15.47, last modified on January 20, 2023

To perform various actions over the UltraWebGrid control, first, you need to locate the row that contains the data you are going to work with. You may also need to find a certain record to make sure that data has been loaded to the grid correctly, and so on. This topic describes how you can search for records in the UltraWebGrid object.

When testing UltraWebGrid controls, use specific methods and properties of the corresponding InfragisticsWebDataGrid object. In order for TestComplete to be able to access this object, the Infragistics Control Support plugins must be installed and enabled. You can call object methods and properties from your keyword tests, as well as from scripts. This topic describes how to work with object properties and methods from your scripts. However, when testing a GridGroupingControl control from your keyword test, you can use the same methods and properties calling them from keyword test operations. For more information, see Keyword Tests Basic Operations.

To find the needed record within the specified UltraWebGrid column, you can use the FindRow method of the InfragisticsWebDataGrid or InfragisticsWebDataGridView object. This method returns the index of the first grid row that contains the needed record. If the row containing the specified value is not found, the method returns -1.

Note that the grid control may display data with special formatting, so the actual value of a particular cell can significantly differ from the cell’s display text. The grid can also contain columns that use lookup combo boxes to display values other than those that are actually stored in the column cells. You should keep this in mind when specifying the sought-for values for your search procedure.

The following example works with the WebDateChooser - DateChooser in Datagrid in User Control sample application, which is part of the Infragistics NetAdvantage 2009 trial download package. It demonstrates how you can locate a grid row by its value in a particular column. The script obtains the UltraWebGrid object, locates the grid row by using the FindRow method and clicks on the found cells.

JavaScript, JScript

function Main ()
{

  var url = "http://my-web-site/web-page-with-ultrawebgrid-2009.aspx";
  Browsers.Item(btIExplorer).Run(url);
  var page = Sys.Browser("*").Page("*");

  // Obtain the grid object
  var Grid = page.Frame("contentBodyIFrame").Frame("main").Form("Form1").Table("igtabUltraWebTab1").Cell(1, 0).Frame("UltraWebTab1_frame0").Form("Form1").Table("Table1").Cell(0, 0).Table("Table2").Cell(1, 0).Table("UltraWebGrid1_main");

  // Locate a row
  var RowIndex = Grid.FindRow(2, "Robert");
  if (RowIndex != -1)
  {
    Grid.ClickCell(RowIndex, 2);
    Log.Message("Value 'Robert' was found in the 2 column.");
  }
}

Python

def Main():

  url = "http://my-web-site/web-page-with-ultrawebgrid-2009.aspx"
  Browsers.Item[btIExplorer].Run(url)
  page = Sys.Browser("*").Page("*")

  # Obtain the grid object
  Grid = page.Frame("contentBodyIFrame").Frame("main").Form("Form1").Table("igtabUltraWebTab1").Cell(1, 0).Frame("UltraWebTab1_frame0").Form("Form1").Table("Table1").Cell(0, 0).Table("Table2").Cell(1, 0).Table("UltraWebGrid1_main")

  # Locate a row
  RowIndex = Grid.FindRow(2, "Robert")
  if (RowIndex != -1):
    Grid.ClickCell(RowIndex, 2)
    Log.Message("Value 'Robert' was found in the 2 column.")

VBScript

Sub Main
  Dim url, page, Grid, RowIndex

  url = "http://my-web-site/web-page-with-ultrawebgrid-2009.aspx"
  Browsers.Item(btIExplorer).Run url
  Set page = Sys.Browser("*").Page("*")

  ' Obtain the grid object
  Set Grid = page.Frame("contentBodyIFrame").Frame("main").Form("Form1").Table("igtabUltraWebTab1").Cell(1, 0).Frame("UltraWebTab1_frame0").Form("Form1").Table("Table1").Cell(0, 0).Table("Table2").Cell(1, 0).Table("UltraWebGrid1_main")

  ' Locate a row
  RowIndex = Grid.FindRow(2, "Robert")
  If RowIndex <> -1 Then
    Call Grid.ClickCell (RowIndex, 2)
    Log.Message ("Value 'Robert' was found in the 2 column.")
  End If
End Sub

DelphiScript

procedure Main;
var url, page, Grid, RowIndex : OleVariant;
begin
  url := 'http://my-web-site/web-page-with-ultrawebgrid-2009.aspx';
  Browsers.Item(btIExplorer).Run(url);
  page := Sys.Browser('*').Page('*');

  // Obtain the grid object
  Grid := page.Frame('contentBodyIFrame').Frame('main').Form('Form1').Table('igtabUltraWebTab1').Cell(1, 0).Frame('UltraWebTab1_frame0').Form('Form1').Table('Table1').Cell(0, 0).Table('Table2').Cell(1, 0).Table('UltraWebGrid1_main');

  // Locate a row
  RowIndex := Grid.FindRow(2, 'Robert');
  if RowIndex <> -1 then
  begin
    Grid.ClickCell (RowIndex, 2);
    Log.Message ('Value "Robert" was found in the 2 column.');
  end;
end;

C++Script, C#Script

function Main ()
{

  var url = "http://my-web-site/web-page-with-ultrawebgrid-2009.aspx";
  Browsers["Item"](btIExplorer)["Run"](url);
  var page = Sys["Browser"]("*")["Page"]("*");

  // Obtain the grid object
  var Grid = page["Frame"]("contentBodyIFrame")["Frame"]("main")["Form"]("Form1")["Table"]("igtabUltraWebTab1")["Cell"](1, 0)["Frame"]("UltraWebTab1_frame0")["Form"]("Form1")["Table"]("Table1")["Cell"](0, 0)["Table"]("Table2")["Cell"](1, 0)["Table"]("UltraWebGrid1_main");

  // Locate a row
  var RowIndex = Grid["FindRow"](2, "Robert");
  if (RowIndex != -1)
  {
    Grid["ClickCell"](RowIndex, 2);
    Log["Message"]("Value 'Robert' was found in the 2 column.");
  }
}

See Also

Working With Infragistics UltraWebGrid
Obtaining and Setting Cell Values in Infragistics UltraWebGrid

Highlight search results