Sorting Data in Infragistics UltraWebGrid

Applies to TestComplete 14.70, last modified on April 22, 2021

The UltraWebGrid control lets end-users sort displayed data. This topic describes the approach that can be used to sort the grid data from 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.

Data displayed in the UltraWebGrid control can be sorted by clicking on the header of the column which you want to sort. The next click on the same header switches between sort directions (from ascending to descending and vice versa). Note that this functionality may be not enabled for some columns. In this case, clicking the column header selects the entire column, and there is no way to sort grid data by using column header clicks.

With TestComplete, you can simulate clicks on UltraWebGrid column headers using the ClickColumnHeader action of the InfragisticsWebDataGrid object.

The following example works with the WebGrid - Client Sorting sample application, which is part of the Infragistics NetAdvantage 2009 trial download package.

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("UltraWebGrid1_main");

  // Click the column header to sort ascending by that column
  Grid.ClickColumnHeader("Company Name");

  aqUtils.Delay (1000);

  // Click the column header again to sort descending by that column
  Grid.ClickColumnHeader("Company Name");
}

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("UltraWebGrid1_main")

  # Click the column header to sort ascending by that column
  Grid.ClickColumnHeader("Company Name")

  aqUtils.Delay (1000)

  # Click the column header again to sort descending by that column
  Grid.ClickColumnHeader("Company Name")

VBScript

Sub Main
  Dim url, page, Grid

  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("UltraWebGrid1_main")

  ' Click the column header to sort ascending by that column
  Call Grid.ClickColumnHeader("Company Name")

  aqUtils.Delay (1000)

  ' Click the column header again to sort descending by that column
  Call Grid.ClickColumnHeader("Company Name")
End Sub

DelphiScript

procedure Main;
var url, page, Grid : 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('UltraWebGrid1_main');

  // Click the column header to sort ascending by that column
  Grid.ClickColumnHeader('Company Name');

  aqUtils.Delay (1000);

  // Click the column header again to sort descending by that column
  Grid.ClickColumnHeader('Company Name');
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"]("UltraWebGrid1_main");

  // Click the column header to sort ascending by that column
  Grid.ClickColumnHeader("Company Name");

  aqUtils.Delay (1000);

  // Click the column header again to sort descending by that column
  Grid.ClickColumnHeader("Company Name");
}

See Also

Working With Infragistics UltraWebGrid
ClickColumnHeader Action (Grid Controls)
Selecting Cells in Infragistics UltraWebGrid
Obtaining and Setting Cell Values in Infragistics UltraWebGrid

Highlight search results