Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Engineering

Collapsible Grid Control API

  • Last UpdatedOct 28, 2024
  • 6 minute read

To create a collapsible grid, the data source must have a defined relationship between data tables. Primary key and foreign key columns are utilized to define this.

Data Tables and Bands

The list of data tables is represented by grid bands (a band is an object that represents a set of related data columns). Each band represents a single table. To establish a heading structure for the tables, they must be linked together using ID and ForeignID identifiers, which point to the parent.

The example displays a heading structure with ID and ForeignID content:

-- Create headings

!parentHeadings = ARRAY()

!parentHeadings[1] = 'ID'

!parentHeadings[2] = 'sItem'

!parentHeadings[3] = 'ForeignID'

!childHeadings = ARRAY()

!childHeadings[1] = 'ID'

!childHeadings[2] = 'sDescription'

!childHeadings[3] = 'sNote'

!childHeadings[4] = 'ForeignID'

General Structure

The defined collapsible grids types are:

  • NetGridControl

  • DataGridControl

  • CollapsibleGridControl

To create a grid with collapsible functionality, use the following classes:

  • CollapsibleDataSource.cs

    The file used for creating tables and hierarchy and calling for binding to Infragistics.

  • CollapsibleGeneralTypeDataSource.cs

    The file used for handling generic pml data source types.

  • CollapsibleGridControl.cs

    The file is the main hub for PML calls by the user, it handles user events and interaction from the user interface level.

  • CollapsibleGridEngine.cs

    The file is used for populating and interacting with tables. It is the main drill down and simplifying functionality of the grid used by other functions of the collapsible grid control.

  • ICollapsibleDataSource.cs

    The interface for extending custom types.

  • ICollapsibleTypeDataSource.cs

    The interface for extending custom types and behaviour.

If the end user does not want to define their own datasource, only the CollapsibleDataSource and CollapsibleGridControl classes are required.

For example, where each of parentTable, childtable and childtable1 are pml arrays:

using namespace 'Aveva.Core.Presentation'

!ndsParent = object CollapsibleDataSource('Parent', !parentHeadings,!parentTable)

!ndsChildFirst = object CollapsibleDataSource('ChildFirst', !childHeadings, !childTableFirst)

!ndsChild = object CollapsibleDataSource('Child', !childHeadings, !childTable)

!ndsGrandChild = object CollapsibleDataSource('GrandChild', !childHeadings, !childTable11)

!ndsChild.AddDataSource(!ndsGrandChild, 'ID', 'ForeignID')

!ndsParent.AddDataSource(!ndsChildFirst,'ID', 'ForeignID')

!ndsParent.AddDataSource(!ndsChild, 'ID', 'ForeignID')

!this.grid.BindToDataSource(!ndsParent)

You can add CollapsibleDataSources to other CollapsibleDataSources as long as a data table and column is defined as a primary key (for example, a column defined in both data tables with the values in the column being unique for the parent table) for the child table to latch onto. In this case ForeignID is the expected child unique identifier. Binding the datasource to the grid control cements this structure, designing the datasource correctly is important.

Note:
The example grid, can be found in the samples folder named pmlgridexample.

Interacting via the grid control is similar to using the netgridcontrol. It is important to note that methods require a datatable name (defined as the title 'Parent'/'Child' in the example) as Collapsible Grids rows are unique in their own level but not for the whole of the grid.

Note:
Selections are on a same level basis. For example, you cannot select both ID 3 and ID 22 in the example grid).

Collapsible Grid PML Interfaces

The following table includes the API calls which have been made available for the Collapsible Grid Control.

Note:
Not all of the API calls have been exposed for PML use.

Note:
You can only use the AVEVA C# Collapsible Grid Control on your own Visual Studio form if you have a design time license for Infragistics.

Name

Type

Purpose

CollapsibleDataSource.cs

CollapsibleDataSource()

Empty constructor.

CollapsibleDataSource(string tableName, Hashtable headings, Hashtable rows)

Constructor, take pml arrays and set the tablename.

AddDataSource(CollapsibleDataSource child, string parentColumnRelationship, string childColumnRelationship)

Add a child data source with given columns for generating collapsible structure.

double ColumnCount()

Return the number of columns of the current data source as real.

ColumnSpecification Column(double iCol)

Get the column specification for a given column (0 index).

string AddRow(Hashtable rowData)

Add the given row to the data source. Returns an identifier based on the data source type.

DeleteRow(Hashtable rowData)

Delete the row as defined by the datasource.

RefreshRow(Hashtable rowData

Refresh/update the datasource row.

string Title

Return the Title, equivalent to datatablename for parameters in other CollapsibleGrid Interfaces.

CollapsibleGridControl.cs

CollapsibleGridControl()

Constructor, also initialises commands and base events.

BindToDataSource(Collapsible DataSource dataSource)

Bind a collapsible grid to a data source, this will generate the structure/levels, column width not kept.

BindToDataSource(Collapsible DataSource dataSource, bool keepColumnWidths)

Bind a collapsible grid to a data source, this will generate the structure/levels, column width not kept is optional.

event PMLNetDelegate.PMLNetEvent Handler OnPopup

Hook for additional actions on the OnPopup event.

event PMLNetDelegate.PMLNetEvent Handler BeforeCellUpdate

Hook for additional actions on the BeforeCellUpdate event.

event PMLNetDelegate.PMLNetEvent Handler AfterCellUpdate

Event to alert the user that a cell has been updated.

event PMLNetDelegate.PMLNetEvent Handler ClickCell

Hook for additional actions on the ClickCell event.

event PMLNetDelegate.PMLNetEvent Handler AfterCellSelectChange

Hook for additional actions on the AfterCellSelectedChange event.

bool FixedRows

Property, true if rows are to be fixed, false if not.

bool ColumnExcelFilter

Property, true if using the excel filter for columns, false if not.

AutoFitColumns(string dataTableName)

Perform autofit on all columns in the grid level corresponding to given datatable name.

SetRowColor(string dataTableName, double rowNum, string strColor)

Set the color of the given row index to string given. Row index separated out by datatable given by name.

SetColumnVisibility(string dataTableName, double colNum, bool visible)

Set the column of the given column in the band corresponding to the table name given.

bool EditableGrid

Set if grid is to be editable or not.

Hashtable GetSelectedRows()

Get selected rows.

Note:
Rows cannot be selected across bands.

HeadersVisibility(string dataTableName, bool visibility)

Set header visibility for band with given data table name.

Note:
If CollapsibleDataSources differ in structure then it is not advisable to turn this off.

GridFiltersVisibility(bool visibility)

Set whether grid filters are visible or not.

SelectRow(string dataTableName, double rowNum)

Select row at given index in band with same datatable name.

AddRowToTable(Hashtable rowData, string dataTableName)

Add row to the end of the band corresponding to table name.

DeleteRowByIndex(string dataTableName, double i)

Delete row at index given for the band corresponding to given datatable name.

Hashtable GetSelectedRowIndexes()

Get the collection of indexes for all selected rows.

SetEditableColumn(string dataTableName, double colNum, bool on)

Set whether column with index colNum in band corresponding to datatable is editable.

bool ColumnSummaries

Set true if column summaries are allowed, false if not.

bool HeaderSort

Set true if headers can be sorted, false if not.

bool OutlookGroupStyle

Set true to use outlook styling for the grid, false if not.

CreateValueList(string strValueList, Hashtable list)

Create a value list for the grid with key strValueList and values list.

bool CheckValueIsInCellValueList(string dataTableName, string strValue, double rowNum, double colNum)

True if valuelist given to corresponding cell matches strValue.

AssignValueListToColumn(string dataTableName, string strValueList, double colNum)

Assign valuelist with key strValueList to the given column.

AssignValueListToCell(string dataTableName, string strValueList, double rowNum, double colNum)

Assign valuelist with key strValueList to the given cell.

RemoveValueListFromCell(string dataTableName, double rowNum, double colNum)

Remove valuelist for the given cell.

For events information is passed out in this format:

OnPopup (Array)

  • Array[0] is the x coordinate of the position

  • Array[1] is the y coordinate of the position

  • Array[2] is the band/datatable name

  • Array[3] is the row index of the row in the band named in Array[2]

AfterSelectChange (Array)

If invoked from a row:

  • Array[0] is the band/datatable name

  • Array[1] are the row indexes of selected rows in the band named in Array[0]

If invoked from a cell:

  • Array[0] is the band/datatable name

  • Array[1] is the column index in the band named in Array[0] of the first selected cell in the collection

  • Array[2] is the row index in the band named in Array[0] of the first selected cell in the collection

  • Array[3] are the row indexes of selected cells in the band named in Array[0]

  • Array[4] are the column indexes of selected cells in the band named in Array[0]

AfterCellUpdate(Array)

  • Array[0] is the row index of the cell

  • Array[1] is the column index of the cell

  • Array[2] is the band/datatable name

BeforeCellUpdate(Array)

  • Array[0] is the new value the cell is to be updated to

  • Array[1] is the row index of the cell

  • Array[2] is the column key of the cell

  • Array[3] is the band/datatable name

  • Array[4] is a true flag, used for other pml variables to signify a change is about to occur

  • Array[5] is an empty string, normally used for storing old values about to be changed

In This Topic
TitleResults for “How to create a CRG?”Also Available in