The GridGroupingControl cells may have embedded buttons that can modify the cell value in a special way, invoke popup editors or custom dialogs, and so on. Examples of these buttons are: push buttons, down arrow buttons, spin buttons and so on. To “press” the cell editor’s button from your test scripts, you can simulate a mouse click on it using the ClickCellXY
action of the SyncfusionEssGrid
object or the Click
action that is common to all onscreen
objects. In any case, you need to know the coordinates of the desired button; cell-relative (in the former case) or grid-relative (in the latter case). It is possible to calculate the button coordinates using internal methods and properties of the GridGroupingControl object. For example, the script below illustrates which methods and properties you can use to determine grid-relative coordinates of the cell’s down arrow button. For more information on the methods and properties used, please refer to the Essential Grid documentation.
In order for TestComplete to have access to internal methods, properties and objects of the GridGroupingControl object, the .NET Application Support plugin must be installed and enabled. |
The following example demonstrates how you can invoke and work with drop-down editors in the GridGroupingControl. This example works with the EmployeeTerritoryOrder sample application that comes with Syncfusion Essential Studio library and by default resides in the following folder:
<Syncfusion>\Windows\Grid.Grouping.Windows\Samples\2.0\Relations And Hierarchy\Employee Territory Order Demo\
The script contains the following routines:
Main
is the “main” routine. It obtains the scripting object corresponding to the GridGroupingControl and clicks on buttons embedded in some grid cells.ClickDropDownButton
simulates a click on the cell’s down arrow button. The routine has the following parameters:- Grid -- The tested GridGroupingControl object.
- View -- Specifies a
SyncfusionEssGridView
object corresponding to a child table or group in which the cell resides. If the cell belongs to an ungrouped top-level table, this parameter should be null (null
in JavaScript, JScript, C#Script and C++Script,None
in Python,Nothing
in VBScript,nil
in DelphiScript). - RowIndex -- The zero-based index of the cell’s row.
- ColumnId -- The caption of the cell’s column or its zero-based index within the table.
The routine performs the following actions:- Clicks the specified cell using the
ClickCell
action. - Checks if the cell contains the down arrow button.
- Calculates the down arrow button bounds.
- Simulates a click on the down arrow button.
OpenMonthCalendar
opens the specified cell’s down arrow calendar and returns aWin32MonthCalendar
object corresponding to the calendar control. To invoke the calendar control, it uses theClickDropDownButton
routine to simulate a mouse click on the down arrow button.The
OpenMonthCalendar
function has four parameters: Grid, View, RowIndex and ColumnId, which have the same meaning as those used by theClickDropDownButton
routine.
JavaScript
function Main ()
{
var p, Grid, ChildTable, Calendar;
// Obtain the grid object and the nested table
p = Sys.Process("EmployeeTerritoryOrder");
p.WinFormsObject("Form1").Maximize();
Grid = p.WinFormsObject("Form1").WinFormsObject("gridGroupingControl1");
ChildTable = Grid.wChildView (0, "Orders");
// Simulate actions in the drop-down MonthCalendar control
Calendar = OpenMonthCalendar (Grid, ChildTable, 0, "OrderDate");
Calendar.SetSelection ("4/25/2007 10:00 AM");
Calendar = OpenMonthCalendar (Grid, ChildTable, 1, "ShippedDate");
Calendar.SetSelection ("3/3/2007 8:00 AM");
Calendar = OpenMonthCalendar (Grid, null, 3, "BirthDate");
Calendar.SetSelection ("12/8/1980");
}
function OpenMonthCalendar (Grid, View, RowIndex, ColumnId)
{
// Invoke the MonthCalendar editor
ClickDropDownButton (Grid, View, RowIndex, ColumnId);
// Get an onscreen object corresponding to the MonthCalendar editor
return Sys.WindowFromHandle(Grid.TableControl.GetNestedCurrentCell().Renderer.calendar.Handle);
}
function ClickDropDownButton (Grid, View, RowIndex, ColumnId)
{
var CellRenderer, bounds, TableWnd;
// Select the cell
if (strictEqual(View, null))
Grid.ClickCell (RowIndex, ColumnId)
else
View.ClickCell (RowIndex, ColumnId);
// Get the cell renderer and redraw the cell
CellRenderer = Grid.TableControl.GetNestedCurrentCell().Renderer;
CellRenderer.PerformLayout (CellRenderer.StyleInfo.TableCellIdentity.RowIndex,
CellRenderer.StyleInfo.TableCellIdentity.ColIndex);
// Check if the cell contains the down arrow button
if (!strictEqual(CellRenderer.DropDownImp, null))
{
// Get the button coordinates
bounds = CellRenderer.DropDownButton.Bounds;
// Get a window object corresponding to the grid table and click on the cell's button
TableWnd = Sys.WindowFromHandle (Grid.TableControl.Handle);
TableWnd.Click (bounds.X + bounds.Width/2, bounds.Y + bounds.Height/2);
}
else
Log.Error ("Cell (" + RowIndex + ", " + ColumnId + ") contains no down arrow button.");
}
JScript
function Main ()
{
var p, Grid, ChildTable, Calendar;
// Obtain the grid object and the nested table
p = Sys.Process("EmployeeTerritoryOrder");
p.WinFormsObject("Form1").Maximize();
Grid = p.WinFormsObject("Form1").WinFormsObject("gridGroupingControl1");
ChildTable = Grid.wChildView (0, "Orders");
// Simulate actions in the drop-down MonthCalendar control
Calendar = OpenMonthCalendar (Grid, ChildTable, 0, "OrderDate");
Calendar.SetSelection ("4/25/2007 10:00 AM");
Calendar = OpenMonthCalendar (Grid, ChildTable, 1, "ShippedDate");
Calendar.SetSelection ("3/3/2007 8:00 AM");
Calendar = OpenMonthCalendar (Grid, null, 3, "BirthDate");
Calendar.SetSelection ("12/8/1980");
}
function OpenMonthCalendar (Grid, View, RowIndex, ColumnId)
{
// Invoke the MonthCalendar editor
ClickDropDownButton (Grid, View, RowIndex, ColumnId);
// Get an onscreen object corresponding to the MonthCalendar editor
return Sys.WindowFromHandle(Grid.TableControl.GetNestedCurrentCell().Renderer.calendar.Handle);
}
function ClickDropDownButton (Grid, View, RowIndex, ColumnId)
{
var CellRenderer, bounds, TableWnd;
// Select the cell
if (View == null)
Grid.ClickCell (RowIndex, ColumnId)
else
View.ClickCell (RowIndex, ColumnId);
// Get the cell renderer and redraw the cell
CellRenderer = Grid.TableControl.GetNestedCurrentCell().Renderer;
CellRenderer.PerformLayout (CellRenderer.StyleInfo.TableCellIdentity.RowIndex,
CellRenderer.StyleInfo.TableCellIdentity.ColIndex);
// Check if the cell contains the down arrow button
if (CellRenderer.DropDownImp != null)
{
// Get the button coordinates
bounds = CellRenderer.DropDownButton.Bounds;
// Get a window object corresponding to the grid table and click on the cell's button
TableWnd = Sys.WindowFromHandle (Grid.TableControl.Handle);
TableWnd.Click (bounds.X + bounds.Width/2, bounds.Y + bounds.Height/2);
}
else
Log.Error ("Cell (" + RowIndex + ", " + ColumnId + ") contains no down arrow button.");
}
Python
def Main ():
# Obtain the grid object and the nested table
p = Sys.Process("EmployeeTerritoryOrder")
p.WinFormsObject("Form1").Maximize()
Grid = p.WinFormsObject("Form1").WinFormsObject("gridGroupingControl1")
ChildTable = Grid.wChildView (0, "Orders")
# Simulate actions in the drop-down MonthCalendar control
Calendar = OpenMonthCalendar (Grid, ChildTable, 0, "OrderDate")
Calendar.SetSelection ("4/25/2007 10:00 AM")
Calendar = OpenMonthCalendar (Grid, ChildTable, 1, "ShippedDate")
Calendar.SetSelection ("3/3/2007 8:00 AM")
Calendar = OpenMonthCalendar (Grid, None, 3, "BirthDate")
Calendar.SetSelection ("12/8/1980")
def OpenMonthCalendar (Grid, View, RowIndex, ColumnId):
# Invoke the MonthCalendar editor
ClickDropDownButton (Grid, View, RowIndex, ColumnId)
# Get an onscreen object corresponding to the MonthCalendar editor
return Sys.WindowFromHandle(Grid.TableControl.GetNestedCurrentCell().Renderer.calendar.Handle)
def ClickDropDownButton (Grid, View, RowIndex, ColumnId):
# Select the cell
if (View == None):
Grid.ClickCell (RowIndex, ColumnId)
else:
View.ClickCell (RowIndex, ColumnId)
# Get the cell renderer and redraw the cell
CellRenderer = Grid.TableControl.GetNestedCurrentCell().Renderer
CellRenderer.PerformLayout (CellRenderer.StyleInfo.TableCellIdentity.RowIndex, CellRenderer.StyleInfo.TableCellIdentity.ColIndex)
# Check if the cell contains the down arrow button
if (CellRenderer.DropDownImp != None):
# Get the button coordinates
bounds = CellRenderer.DropDownButton.Bounds
# Get a window object corresponding to the grid table and click on the cell's button
TableWnd = Sys.WindowFromHandle (Grid.TableControl.Handle)
TableWnd.Click (bounds.X + bounds.Width/2, bounds.Y + bounds.Height/2)
else:
Log.Error ("Cell (" + RowIndex + ", " + ColumnId + ") contains no down arrow button.")
VBScript
Sub Main
Dim p, Grid, ChildTable, Calendar
' Obtain the grid object and the nested table
Set p = Sys.Process("EmployeeTerritoryOrder")
p.WinFormsObject("Form1").Maximize
Set Grid = p.WinFormsObject("Form1").WinFormsObject("gridGroupingControl1")
Set ChildTable = Grid.wChildView (0, "Orders")
' Simulate actions in the drop-down MonthCalendar control
Set Calendar = OpenMonthCalendar (Grid, ChildTable, 0, "OrderDate")
Calendar.SetSelection ("4/25/2007 10:00 AM")
Set Calendar = OpenMonthCalendar (Grid, ChildTable, 1, "ShippedDate")
Calendar.SetSelection ("3/3/2007 8:00 AM")
Set Calendar = OpenMonthCalendar (Grid, Nothing, 3, "BirthDate")
Calendar.SetSelection ("12/8/1980")
End Sub
Function OpenMonthCalendar (Grid, View, RowIndex, ColumnId)
' Invoke the MonthCalendar editor
Call ClickDropDownButton (Grid, View, RowIndex, ColumnId)
' Get an onscreen object corresponding to the MonthCalendar editor
Set OpenMonthCalendar = Sys.WindowFromHandle(Grid.TableControl.GetNestedCurrentCell.Renderer.calendar.Handle)
End Function
Sub ClickDropDownButton (Grid, View, RowIndex, ColumnId)
Dim CellRenderer, bounds, TableWnd
' Select the cell
If View Is Nothing Then
Call Grid.ClickCell (RowIndex, ColumnId)
Else
Call View.ClickCell (RowIndex, ColumnId)
End If
' Get the cell renderer and redraw the cell
Set CellRenderer = Grid.TableControl.GetNestedCurrentCell().Renderer
Call CellRenderer.PerformLayout (CellRenderer.StyleInfo.TableCellIdentity.RowIndex, _
CellRenderer.StyleInfo.TableCellIdentity.ColIndex)
' Check if the cell contains the down arrow button
If Not CellRenderer.DropDownImp Is Nothing Then
' Get the button coordinates
Set bounds = CellRenderer.DropDownButton.Bounds
' Get a window object corresponding to the grid table and click on the cell's button
Set TableWnd = Sys.WindowFromHandle (Grid.TableControl.Handle)
Call TableWnd.Click (bounds.X + bounds.Width/2, bounds.Y + bounds.Height/2)
Else
Log.Error ("Cell (" & RowIndex & ", " & ColumnId & ") contains no down arrow button.")
End If
End Sub
DelphiScript
function OpenMonthCalendar (Grid, View, RowIndex, ColumnId); forward;
procedure ClickDropDownButton (Grid, View, RowIndex, ColumnId); forward;
procedure Main;
var p, Grid, ChildTable, Calendar : OleVariant;
begin
// Obtain the grid object and the nested table
p := Sys.Process('EmployeeTerritoryOrder');
p.WinFormsObject('Form1').Maximize;
Grid := p.WinFormsObject('Form1').WinFormsObject('gridGroupingControl1');
ChildTable := Grid.wChildView[0, 'Orders'];
// Simulate actions in the drop-down MonthCalendar control
Calendar := OpenMonthCalendar (Grid, ChildTable, 0, 'OrderDate');
Calendar.SetSelection ('4/25/2007 10:00 AM');
Calendar := OpenMonthCalendar (Grid, ChildTable, 1, 'ShippedDate');
Calendar.SetSelection ('3/3/2007 8:00 AM');
Calendar := OpenMonthCalendar (Grid, nil, 3, 'BirthDate');
Calendar.SetSelection ('12/8/1980');
end;
function OpenMonthCalendar (Grid, View, RowIndex, ColumnId);
begin
// Invoke the MonthCalendar editor
ClickDropDownButton (Grid, View, RowIndex, ColumnId);
// Get an onscreen object corresponding to the MonthCalendar editor
Result := Sys.WindowFromHandle(Grid.TableControl.GetNestedCurrentCell.Renderer.calendar.Handle);
end;
procedure ClickDropDownButton (Grid, View, RowIndex, ColumnId);
var CellRenderer, bounds, TableWnd : OleVariant;
begin
// Select the cell
if View = nil then
Grid.ClickCell (RowIndex, ColumnId)
else
View.ClickCell (RowIndex, ColumnId);
// Get the cell renderer and redraw the cell
CellRenderer := Grid.TableControl.GetNestedCurrentCell.Renderer;
CellRenderer.PerformLayout (CellRenderer.StyleInfo.TableCellIdentity.RowIndex,
CellRenderer.StyleInfo.TableCellIdentity.ColIndex);
// Check if the cell contains the down arrow button
if CellRenderer.DropDownImp <> nil then
begin
// Get the button coordinates
bounds := CellRenderer.DropDownButton.Bounds;
// Get a window object corresponding to the grid table and click on the cell's button
TableWnd := Sys.WindowFromHandle (Grid.TableControl.Handle);
TableWnd.Click (bounds.X + bounds.Width/2, bounds.Y + bounds.Height/2);
end
else
Log.Error ('Cell (' + aqConvert.VarToStr(RowIndex) + ', ' + aqConvert.VarToStr(ColumnId) + ') contains no down arrow button.');
end;
C++Script, C#Script
function Main ()
{
var p, Grid, ChildTable, Calendar;
// Obtain the grid object and the nested table
p = Sys["Process"]("EmployeeTerritoryOrder");
p["WinFormsObject"]("Form1")["Maximize"]();
Grid = p["WinFormsObject"]("Form1")["WinFormsObject"]("gridGroupingControl1");
ChildTable = Grid["wChildView"](0, "Orders");
// Simulate actions in the drop-down MonthCalendar control
Calendar = OpenMonthCalendar (Grid, ChildTable, 0, "OrderDate");
Calendar["SetSelection"]("4/25/2007 10:00 AM");
Calendar = OpenMonthCalendar (Grid, ChildTable, 1, "ShippedDate");
Calendar["SetSelection"]("3/3/2007 8:00 AM");
Calendar = OpenMonthCalendar (Grid, null, 3, "BirthDate");
Calendar["SetSelection"]("12/8/1980");
}
function OpenMonthCalendar (Grid, View, RowIndex, ColumnId)
{
// Invoke the MonthCalendar editor
ClickDropDownButton (Grid, View, RowIndex, ColumnId);
// Get an onscreen object corresponding to the MonthCalendar editor
return Sys["WindowFromHandle"](Grid["TableControl"]["GetNestedCurrentCell"]()["Renderer"]["calendar"]["Handle"]);
}
function ClickDropDownButton (Grid, View, RowIndex, ColumnId)
{
var CellRenderer, bounds, TableWnd;
// Select the cell
if (View == null)
Grid["ClickCell"](RowIndex, ColumnId)
else
View["ClickCell"](RowIndex, ColumnId);
// Get the cell renderer and redraw the cell
CellRenderer = Grid["TableControl"]["GetNestedCurrentCell"]()["Renderer"];
CellRenderer["PerformLayout"](CellRenderer["StyleInfo"]["TableCellIdentity"]["RowIndex"],
CellRenderer["StyleInfo"]["TableCellIdentity"]["ColIndex"]);
// Check if the cell contains the down arrow button
if (CellRenderer["DropDownImp"] != null)
{
// Get the button coordinates
bounds = CellRenderer["DropDownButton"]["Bounds"];
// Get a window object corresponding to the grid table and click on the cell's button
TableWnd = Sys["WindowFromHandle"](Grid["TableControl"]["Handle"]);
TableWnd["Click"](bounds["X"] + bounds["Width"]/2, bounds["Y"] + bounds["Height"]/2);
}
else
Log["Error"]("Cell (" + RowIndex + ", " + ColumnId + ") contains no down arrow button.");
}
See Also
Working With Syncfusion GridGroupingControl
Selecting Cells in Syncfusion GridGroupingControl
Activating and Closing In-place Editors in Syncfusion GridGroupingControl
Obtaining and Setting Cell Values in Syncfusion GridGroupingControl