Expanding and Collapsing Rows in Infragistics UltraWebGrid

Applies to TestComplete 14.20, last modified on September 11, 2019

Infragistics UltraWebGrid supports hierarchical data representation. If the grid displays data of multiple nested data tables, each data row can have child rows containing data associated with this row. To view child data, a user needs to expand its parent row and the child table itself. This topic explains how you can expand and collapse rows in the UltraWebGrid control from your test scripts.

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 expand or collapse rows of the UltraWebGrid control, you can use the Expand and Collapse actions of the InfragisticsWebDataGrid or InfragisticsWebDataGridView object. The actions of the InfragisticsWebDataGrid object apply to the rows of the main data view, whereas the InfragisticsWebDataGridView actions affect the rows of the respective child data view. The wExpanded property of these objects indicates the current expanded state of a particular row.

The following example works with the UltraWebGrid - Manual Load on Demand sample application, which is part of the Infragistics NetAdvantage 2009 trial download package.

It illustrates how you can expand and collapse rows by using actions provided by TestComplete:

JavaScript, JScript

function ExtendedExpandCollapse()
{

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

  var Grid = page.Frame("contentBodyIFrame").Frame("main").Form("Form1").Table("igtabUltraWebTab1").Cell(1, 0).Frame("UltraWebTab1_frame0").Form("WebForm2").Table("Table1").Cell(0, 0).Table("UltraWebGrid1_main");

  // Expand the first row in the main view
  Grid.Expand(0);
  // Expand the second row of the first row's data view
  Grid.wChildView(0).Expand(1);
  aqUtils.Delay(1000);
  // Collapse the second row of the first row's data view
  Grid.wChildView(0).Collapse(1);
  // Collapse the first row in the main view
  Grid.Expand(0, false);
}

Python

def ExtendedExpandCollapse():

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

  Grid = page.Frame("contentBodyIFrame").Frame("main").Form("Form1").Table("igtabUltraWebTab1").Cell(1, 0).Frame("UltraWebTab1_frame0").Form("WebForm2").Table("Table1").Cell(0, 0).Table("UltraWebGrid1_main")

  # Expand the first row in the main view
  Grid.Expand(0)
  # Expand the second row of the first row's data view 
  Grid.wChildView[0].Expand(1)
  aqUtils.Delay(1000)
  # Collapse the second row of the first row's data view 
  Grid.wChildView[0].Collapse(1)
  # Collapse the first row in the main view 
  Grid.Expand(0, False)

VBScript

Sub ExtendedExpandCollapse

  Dim url, page, Grid
  ' Obtain the grid object
  url = "http://my-web-site/web-page-with-ultrawebgrid-2009.aspx"
  Browsers.Item(btIExplorer).Run url
  Set page = Sys.Browser("*").Page("*")

  Set Grid = page.Frame("contentBodyIFrame").Frame("main").Form("Form1").Table("igtabUltraWebTab1").Cell(1, 0).Frame("UltraWebTab1_frame0").Form("WebForm2").Table("Table1").Cell(0, 0).Table("UltraWebGrid1_main")

  ' Expand the first row in the main view
  Call Grid.Expand(0)
  ' Expand the second row of the first row's data view
  Call Grid.wChildView(0).Expand(1)
  aqUtils.Delay(1000)
  ' Collapse the second row of the first row's data view
  Call Grid.wChildView(0).Collapse(1)
  ' Collapse the first row in the main view
  Call Grid.Expand(0, False)
End Sub

DelphiScript

procedure ExtendedExpandCollapse;
  var url, page, Grid: OleVariant;
begin

  // Obtain the grid object
  url := 'http://my-web-site/web-page-with-ultrawebgrid-2009.aspx';
  Browsers.Item(btIExplorer).Run(url);
  page := Sys.Browser('*').Page('*');

  Grid := page.Frame('contentBodyIFrame').Frame('main').Form('Form1').Table('igtabUltraWebTab1').Cell(1, 0).Frame('UltraWebTab1_frame0').Form('WebForm2').Table('Table1').Cell(0, 0).Table('UltraWebGrid1_main');

  // Expand the first row in the main view
  Grid.Expand(0);
  // Expand the second row of the first row's data view
  Grid.wChildView[0].Expand(1);
  aqUtils.Delay(1000);
  // Collapse the second row of the first row's data view
  Grid.wChildView[0].Collapse(1);
  // Collapse the first row in the main view
  Grid.Expand(0, False);
end;

C++Script, C#Script

function ExtendedExpandCollapse()
{

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

  var Grid = page["Frame"]("contentBodyIFrame")["Frame"]("main")["Form"]("Form1")["Table"]("igtabUltraWebTab1")["Cell"](1, 0)["Frame"]("UltraWebTab1_frame0")["Form"]("WebForm2")["Table"]("Table1")["Cell"](0, 0)["Table"]("UltraWebGrid1_main");

  // Expand the first row in the main view
  Grid["Expand"](0);
  // Expand the second row of the first row's data view
  Grid["wChildView"](0)["Expand"](1);
  aqUtils["Delay"](1000);
  // Collapse the second row of the first row's data view
  Grid["wChildView"](0)["Collapse"](1);
  // Collapse the first row in the main view
  Grid["Expand"](0, false);
}

See Also

Working With Infragistics UltraWebGrid
Expand Action (Grid Controls)
Collapse Action (Grid Controls)
wExpanded Property (Grid Controls)

Highlight search results