Working With Developer Express Quantum Grid - Getting Cell Values
Test and Monitor | Posted April 19, 2007

To obtain values displayed in cells of the Developer Express
QuantumGrid control, you should use the internal methods and proeprties
of the grid. This article describes these properties and contains
sample code that demonstrates how you can obtain the cell values.

To get cell values, TestComplete should have access to the internal methods and properties of the TcxGrid object. TcxGrid is the class name of the QuantumGrid control. That is, the tested application must be compiled as an Open Application with debug information.

QuantumGrid may contain several node levels. To determine how the data is displayed by a level, the QuantumGrid use view objects. To obtain the text displayed in a particular cell, use the following method of the view object:

ViewObj.DataController.DisplayTexts(RowIndex, ColumnIndex)

This method returns the text that is shown in the grid cells. The RowIndex and ColumnIndex parameters specify the row and column indexes of the cell. Both indexes are zero-based.

The following sample demonstrates how you can use this method to obtain cell values. The sample contains the following routines:

  • Main - The “main” routine of the sample. It contains the scripting object that corresponds to the tested grid object, calls the GetCellValue function to obtain the cell’s text and then posts the value returned by this function to the test log.
  • GetCellValue - This function returns the text of the specified the grid cell. The function uses the following parameters:
    • grid - The scripting object that corresponds to the tested grid control.
    • view - The view object that is used to display the data. If this parameter is Nothing (VBScript), null (JScript, C++Script, C#Script) or nil (DelphiScript), the routine assumes that you are working with the view associated with the root level.
    • rowIndex - A zero-based index of the desired row.
    • columnId - The caption of the desired column or the column index (zero-based) among other visible columns.

    The routine performs the following actions:

    • Checks if the view parameter is null and, if it is, uses the grid’s ActiveView property to obtain the view object that corresponds to the root level.
    • Calls the GetColumn script function to obtain the column object for the desired cell.
    • Use the view object’s ViewData.Rows(rowIndex) property to obtain the row object that corresponds to the row containing the desired cell.
    • Calls the view’s DataController.DisplayTexts method to obtain the cell’s text.
  • GetColumn - A helper routine that is used to obtain a column object by the column caption or index.

One more way to obtain the cell text is to use the following property of the view object:

ViewObj.ViewData.Rows(rowIndex).DisplayTexts(columnIndex)

The following sample demonstrates how you can use this property:

Close

By submitting this form, you agree to our
Terms of Use and Privacy Policy

Thanks for Subscribing

Keep an eye on your inbox for more great content.

Continue Reading

Add a little SmartBear to your life

Stay on top of your Software game with the latest developer tips, best practices and news, delivered straight to your inbox