Activating and Closing In-place Editors in Infragistics UltraWebGrid

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

Infragistics UltraWebGrid lets users change data directly within grid cells. To modify cell values, you need to perform certain actions with a cell’s in-place editor. This topic describes how you can activate the editor and apply changes you have made:

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.
Activating In-place Editors

The focused cell’s in-place editor can be activated in one of the following ways:

  • By clicking the cell. To simulate cell clicks, you can use the ClickCell and DblClickCell methods of the InfragisticsWebDataGrid or InfragisticsWebDataGridView object.
  • By pressing the F2 key. To simulate keystrokes, use the Keys action. Note that you need to send keystrokes to the frame, not to the grid control.
  • By typing into the focused cell. At that, the cell’s value is replaced with the typed value.

The following example works with the Cell Editors 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 frame
  var frame = page.Frame("contentBodyIFrame").Frame("main").Form("Form1").Table("igtabUltraWebTab1").Cell(1, 0).Frame("UltraWebTab1_frame0");

  // Obtain the grid object
  var grid = frame.Form("ctl00").Table("Table1").Cell(0, 0).Table("UltraWebGrid1_main");

  // Simulate double-clicking the cell
   Grid.DblClickCell(3, "Double");

  // Simulate pressing the F2 shortcut
  // Grid.ClickCell(3, "Double");
  // frame.Keys ("[F2]");
}

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 frame
  frame = page.Frame("contentBodyIFrame").Frame("main").Form("Form1").Table("igtabUltraWebTab1").Cell(1, 0).Frame("UltraWebTab1_frame0")

  # Obtain the grid object
  grid = frame.Form("ctl00").Table("Table1").Cell(0, 0).Table("UltraWebGrid1_main")

  # Simulate double-clicking the cell
  Grid.DblClickCell(3, "Double")

  # Simulate pressing the F2 shortcut
  # Grid.ClickCell(3, "Double")
  # frame.Keys ("[F2]")

VBScript

Sub Main
  Dim url, page, frame, grid

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

  ' Obtain the frame
  Set frame = page.Frame("contentBodyIFrame").Frame("main").Form("Form1").Table("igtabUltraWebTab1").Cell(1, 0).Frame("UltraWebTab1_frame0")

  ' Obtain the grid object
  Set grid = frame.Form("ctl00").Table("Table1").Cell(0, 0).Table("UltraWebGrid1_main")

  ' Simulate double-clicking the cell
  Call Grid.DblClickCell(3, "Double")

  ' Simulate pressing the F2 shortcut
  ' Call Grid.ClickCell(3, "Double")
  ' frame.Keys "[F2]"
End Sub

DelphiScript

procedure Main;
var url, page, frame, 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 frame
  frame := page.Frame('contentBodyIFrame').Frame('main').Form('Form1').Table('igtabUltraWebTab1').Cell(1, 0).Frame('UltraWebTab1_frame0');

  // Obtain the grid object
  grid := frame.Form('ctl00').Table('Table1').Cell(0, 0).Table('UltraWebGrid1_main');

  // Simulate double-clicking the cell
   Grid.DblClickCell(3, 'Double');

  // Simulate pressing the F2 shortcut
  // Grid.ClickCell(3, 'Double');
  // frame.Keys ('[F2]');
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 frame
  var frame = page["Frame"]("contentBodyIFrame")["Frame"]("main")["Form"]("Form1")["Table"]("igtabUltraWebTab1")["Cell"](1, 0)["Frame"]("UltraWebTab1_frame0");

  // Obtain the grid object
  var grid = frame["Form"]("ctl00")["Table"]("Table1")["Cell"](0, 0)["Table"]("UltraWebGrid1_main");

  // Simulate double-clicking the cell
   Grid["DblClickCell"](3, "Double");

  // Simulate pressing the F2 shortcut
  // Grid["ClickCell"](3, "Double");
  // frame["Keys"] ("[F2]");
}
Closing In-place Editors

After you have inputted a new cell value, you need to close the editor and save the changes you have made. You can do this simulating the Enter keystroke.

The following code snippet demonstrates how to change the grid cell value and finish editing.

Two notes:
  • To set the new value to the cell and finish editing, the routine sends keystrokes to the activated in-place editor, not to the grid object or the frame.

  • The sample code implies that the cells whose values are changed contain boxes to which text can be entered. This sample works well for most types of in-place editors, but the UltraWebGrid control can also use specific in-place editors. For instance, the grid can contain columns that use the date chooser control to set the date. So, you should keep this in mind when setting cells' values. If you are not sure what data format a cell supports, you can record a script and check how TestComplete recognizes it.

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 frame
  var frame = page.Frame("contentBodyIFrame").Frame("main").Form("Form1").Table("igtabUltraWebTab1").Cell(1, 0).Frame("UltraWebTab1_frame0");

  // Obtain the grid object
  var grid = frame.Form("ctl00").Table("Table1").Cell(0, 0).Table("UltraWebGrid1_main");

  // Obtain the in-place editor
  var textbox = grid.Cell(1, 0).Panel("UltraWebGrid1_div").Table("G_UltraWebGrid1").Cell(3, 2).TextNode(0);

  // Set the new value to the cell
  grid.DblClickCell(3, "Double");
  textbox.Keys ("14");

  // Finish editing the cell
  textbox.Keys ("[Enter]");
}

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 frame
  frame = page.Frame("contentBodyIFrame").Frame("main").Form("Form1").Table("igtabUltraWebTab1").Cell(1, 0).Frame("UltraWebTab1_frame0")

  # Obtain the grid object
  grid = frame.Form("ctl00").Table("Table1").Cell(0, 0).Table("UltraWebGrid1_main")

  # Obtain the in-place editor
  textbox = grid.Cell(1, 0).Panel("UltraWebGrid1_div").Table("G_UltraWebGrid1").Cell(3, 2).TextNode(0)

  # Set the new value to the cell
  grid.DblClickCell(3, "Double")
  textbox.Keys ("14")

  # Finish editing the cell
  textbox.Keys ("[Enter]")

VBScript

Sub Main
  Dim url, page, frame, grid, textbox

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

  ' Obtain the frame
  Set frame = page.Frame("contentBodyIFrame").Frame("main").Form("Form1").Table("igtabUltraWebTab1").Cell(1, 0).Frame("UltraWebTab1_frame0")

  ' Obtain the grid object
  Set grid = frame.Form("ctl00").Table("Table1").Cell(0, 0).Table("UltraWebGrid1_main")

  ' Obtain the in-place editor
  Set textbox = grid.Cell(1, 0).Panel("UltraWebGrid1_div").Table("G_UltraWebGrid1").Cell(3, 2).TextNode(0)

  ' Set the new value to the cell
  Call grid.DblClickCell(3, "Double")
  Call textbox.Keys ("14")

  ' Finish editing the cell
  Call textbox.Keys ("[Enter]")
End Sub

DelphiScript

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

  // Obtain the frame
  frame := page.Frame('contentBodyIFrame').Frame('main').Form('Form1').Table('igtabUltraWebTab1').Cell(1, 0).Frame('UltraWebTab1_frame0');

  // Obtain the grid object
  grid := frame.Form('ctl00').Table('Table1').Cell(0, 0).Table('UltraWebGrid1_main');

  // Obtain the in-place editor
  textbox := grid.Cell(1, 0).Panel('UltraWebGrid1_div').Table('G_UltraWebGrid1').Cell(3, 2).TextNode(0);

  // Set the new value to the cell
  grid.DblClickCell(3, 'Double');
  textbox.Keys ('14');

  // Finish editing the cell
  textbox.Keys ('[Enter]');
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 frame
  var frame = page["Frame"]("contentBodyIFrame")["Frame"]("main")["Form"]("Form1")["Table"]("igtabUltraWebTab1")["Cell"](1, 0)["Frame"]("UltraWebTab1_frame0");

  // Obtain the grid object
  var grid = frame["Form"]("ctl00")["Table"]("Table1")["Cell"](0, 0)["Table"]("UltraWebGrid1_main");

  // Obtain the in-place editor
  var textbox = grid["Cell"](1, 0)["Panel"]("UltraWebGrid1_div")["Table"]("G_UltraWebGrid1")["Cell"](3, 2)["TextNode"](0);

  // Set the new value to the cell
  grid["DblClickCell"](3, "Double");
  textbox["Keys"] ("14");

  // Finish editing the cell
  textbox["Keys"] ("[Enter]");
}

You may also need to cancel editing and discard any changes made to the cell value. For this purpose, you can send the Esc keystroke to the in-place editor:

JavaScript, JScript

textbox.Keys ("[Esc]");

Python

textbox.Keys ("[Esc]")

VBScript

Call textbox.Keys ("[Esc]")

DelphiScript

textbox.Keys ('[Esc]');

C++Script, C#Script

textbox["Keys"] ("[Esc]");

See Also

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

Highlight search results