Grids based on SDTs or Business Components

GridIcon | LayoutGrid | FreeStyleGridIcon Description

This page explains the general aspects of grids based on SDT's. These nodes are a particular case of Grid node and Grid (SD) nodes, so bear in mind that this page contains information only about things specific to this type of grid. If you can't find information about a certain feature that may be a generic to all types of grids, check the Grid node or Grid (SD) page.

A grid is defined to be "based on an SDT" when a value has been set in the "Grid SDT" property. This type of grid may contain SDTVariable (grid) or Variable (grid) nodes inside its Grid Columns or FreeStyleSection nodes, but no Attribute (grid) nodes.

This kind of grid should be used only when it's not possible to use any of the other options. This implies that the data cannot be obtained (or is obtained with great difficulty) using a foreach command, and there is no data provider available to load the required data.

This can be extremely useful in application integration scenarios, for example, to load a grid using the result of a web service call, or calling an external object to obtain the data. In fact, the examples shown in this page are taken from an integration with the GAM API done using K2BWebPanelDesigner.

To simplify the process of creating grids with no base table, the add sdt action can be used.

Runtime appearance

The runtime appearance of a grid with base table is equal to the appearance of a generic Grid node or Grid (SD).

Properties

Name Value
SDT or BC property Determines the SDT or Business component that is used in this attributes node (if any). See Add SDT or Add Business Component for more information.
SDT or BC Level property Contains the name of the SDT level that applies to this attributes node (if any).
Get SDT On Grid Paging

When grids are loaded from an SDT, two options are available: that the SDT loading procedure handles paging, or that the procedure returns all values and then the Designer implements paging over this set.

The first option has the advantage of avoiding the costs of loading the SDT, given that the developer is always free to load only the items visible in the current page. To do so, the developer must consider the variable “&CurrentPage_{GridName}” and the value of the “Page” property within the node.

On the other hand, the second option makes programming easier because the developer loads the SDT to be displayed only once, and the Web Panel Designer will generate code to move between pages (if they exist).

When this property is set to “True”, the SDT will be reloaded every time that the end user changes the page on the grid. In this case, the subroutine “U_LoadSDT” will be invoked every time the page is changed. The developer must consider the user's position in the grid to perform the loading in the subroutine.

On the other hand, when the property value is “False”, the subroutine will be invoked only once in the Refresh event. It will not be invoked again by the Designer. In this case, the developer doesn't need to take the user's position on the page into account when loading the SDT.

Important: This property is available only in grids that correspond to an SDT's root level.

SDT or BC variable name property Sets the name of the variable used

Events associated to this node

The main event associated to this node is Grid.Load event. This event cannot be modified by the developer.

Inside this event, a call is made to the "U_LoadRowVars" subroutine. This subroutine allows the developer to modify the content of each row in the grid. For example, if the grid contains standard Variable (grid) nodes along with the SDTVariable (grid) nodes, this subroutine can be used to set those variables. To access the item in the SDT collection that is being loaded into the row, the CurrentItem property can be used.

The "U_LoadSDT" subroutine allows the developer to load the contents of the SDT. Using this subroutine the developer can load the SDT using any mechanisms available in GeneXus. This subroutine may be invoked only once per page load, or in every page change. This behaviour is controlled via the property "Get SDT On Grid Paging". The developer must provide an implementation consistent with the option chosen in that property.

For more information see Add SDT.

Notes:

  • The "Get SDT On Grid Paging" property and "U_LoadSDT" subroutine are only available in grids that don't correspond to sublevels of a greater SDT.
  • In grids that correspond to sublevels within a larger structure, paging can be done only in the grid corresponding to the first level of the SDT (if the SDT root is not a collection, paging cannot be done in the generated grids).
  • In grids that correspond to sublevels, the “Page” property is not displayed, and its value is assumed to be equal to zero; that is to say, all the elements in the level are displayed.
  • Filters can be added to this type of grid. K2BTools will add this filters to the user interface, however, it will not add any code or condition to filter the data. The developer should use the filter variables in the U_LoadSDT subroutine to filter the data. As an example if the SDT is loaded from a procedure, this filter should be parameters of the procedure.

Variables associated to this node

Name Description
SDT or BC variable name property

The SDT used in this grid. Only generated if this grid corresponds to the root level of the SDT.

If the grid is part of a nested SDT structure, the variable used is generated by the structure's root.

User subroutines associated to this node

In the following table, {InternalName} should be replaced with the value of the property "Name (Id)" of the grid. Only events specific to this type of grid are shown. To see generic grid properties, check the Grid node page.

Name Moment of execution Detailed description and possible uses
'U_LoadRowVars({InternalName})' This subroutine is invoked inside load event.

This subroutine is called by K2BWebPanelDesigner to obtain the values for variables shown in the grid.

'U_LoadSDT({InternalName})' This subroutine can be invoked in various scenarios

This subroutine allows the developer to load the contents of the SDT. This subroutine is generated only if the grid corresponds to the root node of the SDT structure. If that is not the case, the developer must use the subroutine generated at the structure's root level to load this grid.