Activating and Closing In-place Editors in Syncfusion GridGroupingControl

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

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

To perform these actions, TestComplete should have access to internal objects, properties and methods of the GridGroupingControl object. For this purpose, the .NET Application Support and Syncfusion Systems Control Support plugins must be installed and enabled. The latter lets you work with the GridGroupingControl controls using methods and properties of the SyncfusionEssGrid object. Without this plugin, you will not be able to work with controls using their internal methods and properties.

When testing Syncfusion GridGroupingControl controls, use specific methods and properties of the corresponding SyncfusionEssGrid object. You can call these methods and properties from your keyword tests, as well as from scripts. This topic describes how to work with an object’s 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

It is possible to activate the focused cell’s in-place editor in the following ways:

  • By clicking the cell (if the grid’s Model.ActivateCurrentCellBehavior property is “DblClickOnCell”, double click is required). To simulate cell clicks, you can use the ClickCell and DblClickCell actions.
  • By pressing the F2 key. To send keystrokes to the grid control, use the Keys action.
  • By typing into the focused cell. At that, the cell’s value is replaced by the value typed.
  • By calling the BeginEdit method of the current grid cell (the object returned by the GridObj.TableControl.GetCurrentNestedCell() method).

The following ActivateCellEditor routine demonstrates how to implement some of the described approaches. Its Grid parameter specifies the tested GridGroupingControl.

JavaScript, JScript

function ActivateCellEditor (Grid)
{
  var CurrentCell = Grid.TableControl.GetNestedCurrentCell();
  if (! CurrentCell.IsEditing)
  {
    // Use any of the following statements --

    // Simulate the F2 shortcut
    Grid.Keys ("[F2]")

    // Call the BeginEdit method of the current cell:
    // CurrentCell.BeginEdit();
  }
}

Python

def ActivateCellEditor (Grid):
  CurrentCell = Grid.TableControl.GetNestedCurrentCell()
  if not CurrentCell.IsEditing:
    # Use any of the following statements --

    # Simulate the F2 shortcut
    Grid.Keys ("[F2]")

    # Call the BeginEdit method of the current cell:
    # CurrentCell.BeginEdit()

VBScript

Sub ActivateCellEditor (Grid)
  Dim CurrentCell
  Set CurrentCell = Grid.TableControl.GetNestedCurrentCell
  If Not CurrentCell.IsEditing Then
    ' Use any of the following statements --

    ' Simulate the F2 shortcut
    Grid.Keys "[F2]"

    ' Call the BeginEdit method of the current cell:
    ' CurrentCell.BeginEdit
  End If
End Sub

DelphiScript

procedure ActivateCellEditor (Grid);
var CurrentCell : OleVariant;
begin
  CurrentCell := Grid.TableControl.GetNestedCurrentCell;
  if not CurrentCell.IsEditing then
  begin
    // Use any of the following statements --

    // Simulate the F2 shortcut
    Grid.Keys ('[F2]')

    // Call the BeginEdit method of the current cell:
    // CurrentCell.BeginEdit;
  end
end;

C++Script, C#Script

function ActivateCellEditor (Grid)
{
  var CurrentCell = Grid["TableControl"]["GetNestedCurrentCell"]();
  if (! CurrentCell["IsEditing"])
  {
    // Use any of the following statements --

    // Simulate the F2 shortcut
    Grid["Keys"]("[F2]")

    // Call the BeginEdit method of the current cell:
    // CurrentCell["BeginEdit"]();
  }
}

Closing In-place Editors

After you have inputted the new cell value, you need to close the editor and save the changes made. You can do this in two ways:

  • By simulating the Enter key press.
  • By calling the EndEdit method of the object corresponding to the current grid cell.

The code snippet below contains the CloseCellEditor routine that can be used to finish editing the grid cell value. The Grid parameter of this routine specifies the GridGroupingControl under which the action is performed.

JavaScript, JScript

function CloseCellEditor (Grid)
{
  // Use any of the following statements --

  // Simulate the Enter keypress
  Grid.Keys ("[Enter]");

  // Call the EndEdit method of the current cell:
  // Grid.TableControl.GetNestedCurrentCell().EndEdit();
}

Python

def CloseCellEditor (Grid):
  # Use any of the following statements --

  # Simulate the Enter keypress
  Grid.Keys ("[Enter]")

  # Call the EndEdit method of the current cell:
  # Grid.TableControl.GetNestedCurrentCell().EndEdit()

VBScript

Sub CloseCellEditor (Grid)
  ' Use any of the following statements --

  ' Simulate the Enter keypress
  Grid.Keys "[Enter]"

  ' Call the EndEdit method of the current cell:
  ' Grid.TableControl.GetNestedCurrentCell.EndEdit
End Sub

DelphiScript

procedure CloseCellEditor (Grid);
begin
  // Use any of the following statements --

  // Simulate the Enter keypress
  Grid.Keys ('[Enter]');

  // Call the EndEdit method of the current cell:
  // Grid.TableControl.GetNestedCurrentCell.EndEdit;
end;

C++Script, C#Script

function CloseCellEditor (Grid)
{
  // Use any of the following statements --

  // Simulate the Enter keypress
  Grid["Keys"]("[Enter]");

  // Call the EndEdit method of the current cell:
  // Grid["TableControl"]["GetNestedCurrentCell"]["EndEdit"]();
}

You may also need to cancel the editing and discard any changes made to the cell value. For this purpose, you can either send the Esc key press to the grid control, or use the CancelEdit method of the current grid cell. The CancelEdit routine in the example below demonstrates how to do this:

JavaScript, JScript

function CancelEdit (Grid)
{
  // Use any of the following statements --

  // Simulate the Esc keypress
  Grid.Keys ("[Esc]");

  // Call the CurrentCell.CancelEdit method:
  // Grid.TableControl.GetNestedCurrentCell().CancelEdit();
}

Python

def CancelEdit (Grid):
  # Use any of the following statements --

  # Simulate the Esc keypress
  Grid.Keys ("[Esc]")

  # Call the CurrentCell.CancelEdit method:
  # Grid.TableControl.GetNestedCurrentCell().CancelEdit()

VBScript

Sub CancelEdit (Grid)
  ' Use any of the following statements --

  ' Simulate the Esc keypress
  Grid.Keys "[Esc]"

  ' Call the CancelEdit method of the current cell:
  ' Grid.TableControl.GetNestedCurrentCell.CancelEdit
End Sub

DelphiScript

procedure CancelEdit (Grid);
begin
  // Use any of the following statements --

  // Simulate the Esc keypress
  Grid.Keys ('[Esc]');

  // Call the CurrentCell.CancelEdit method:
  // Grid.TableControl.GetNestedCurrentCell.CancelEdit;
end;

C++Script, C#Script

function CancelEdit (Grid)
{
  // Use any of the following statements --

  // Simulate the Esc keypress
  Grid["Keys"]("[Esc]");

  // Call the CurrentCell.CancelEdit method:
  // Grid["TableControl"]["GetNestedCurrentCell"]["CancelEdit"]();
}

See Also

Working With Syncfusion GridGroupingControl
Selecting Cells in Syncfusion GridGroupingControl
Obtaining and Setting Cell Values in Syncfusion GridGroupingControl
Clicking In-place Editors' Buttons in Syncfusion GridGroupingControl

Highlight search results