Skip to content

DTO_BaseTable

Class · Group: Data Transfer Objects

apex
@JsonAccess(serializable='always' deserializable='always') global virtual class DTO_BaseTable extends DTO_JsonBase

Extends: DTO_JsonBase

A Data Transfer Object (DTO) class that structures webservice handler responses into a common table format, providing column and row handling for a unified data view. Supports functionality for dynamic column definition and row addition.

Since: 1.0

Example:

apex
DTO_BaseTable table = new DTO_BaseTable();
table.addColumn('Account Name', 'name', 'text', true);
table.addColumn('Revenue', 'revenue', 'currency');
table.addRow(new Map<String, Object>{'name' => 'Acme Corp', 'revenue' => 50000});

Properties

PropertyDescription
global List columnsRetrieves the list of columns defined in the table.
global List rowsRetrieves all rows added to the table.

Fields

FieldDescription
global transient List tableColumnsList of table columns within this table
global transient List tableRowsList of table rows within this table

Methods

MethodDescription
global void addColumn(String label, String fieldName, String type)Adds a new column to the table with the specified label, field name, and type.
global void addColumn(String label, String fieldName, String type, Boolean sortable)Adds a new column to the table with specified label, field name, type, and sortable property.
global void addRow(Object anObject)Adds a new data row to the table.

Inner Classes

ClassDescription
DTO_ColumnRepresents a column in the DTO_BaseTable, containing properties for label, field name, type, and sorting ability.

Property Details

columns

apex
@AuraEnabled global List<DTO_BaseTable.DTO_Column> columns

Type: List

Retrieves the list of columns defined in the table. Each column can have a label, field name, data type, and sortable setting. Enables access to the column definitions for display and sorting purposes.

Since:

Example:

rows

apex
@AuraEnabled global List<Object> rows

Type: List

Retrieves all rows added to the table. Each row contains data matching the fields and types specified in the column definitions.

Since:

Example:


Method Details

addColumn

apex
global void addColumn(String label, String fieldName, String type)

Adds a new column to the table with the specified label, field name, and type. The column will not be sortable by default. Useful for defining table structure for row data.

Parameters:

  • label (String) - The display text for the column header.
  • fieldName (String) - The field name to map data from rows to this column.
  • type (String) - The data type of the column (e.g., 'text', 'number'), see documentation for types here:

@link https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/documentation

Since: 1.0

Example:

apex
instance.addColumn('My Label', 'myName', 'value');

addColumn

apex
global void addColumn(String label, String fieldName, String type, Boolean sortable)

Adds a new column to the table with specified label, field name, type, and sortable property. Supports column sorting where applicable and customizable table views.

Parameters:

  • label (String) - The display text for the column header.
  • fieldName (String) - The field name to map data from rows to this column.
  • type (String) - The data type of the column (e.g., 'text', 'number').
  • sortable (Boolean) - A Boolean indicating if the column should support sorting.

@link https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/documentation

Since: 1.0

Example:

apex
instance.addColumn('My Label', 'myName', 'value', true);

addRow

apex
global void addRow(Object anObject)

Adds a new data row to the table. The data should be structured to match the columns defined in the table. Extending classes may override this method for custom row handling.

Parameters:

  • anObject (Object) - The data object representing a row to be added to the table.

Since: 1.0

Example:

apex
instance.addRow('value');

Field Details

tableColumns

apex
global transient List<DTO_BaseTable.DTO_Column> tableColumns

Type: List

List of table columns within this table

Since: 1.0

Example:

apex
DTO_BaseTable table = new DTO_BaseTable();
table.addColumn('Account Name', 'name', 'text', true);
table.addColumn('Revenue', 'revenue', 'currency');
List<DTO_BaseTable.DTO_Column> columns = table.tableColumns;

tableRows

apex
global transient List<Object> tableRows

Type: List

List of table rows within this table

Since: 1.0

Example:

apex
DTO_BaseTable table = new DTO_BaseTable();
table.addRow(new Map<String, Object>{'name' => 'Acme Corp', 'revenue' => 50000});
table.addRow(new Map<String, Object>{'name' => 'Global Inc', 'revenue' => 75000});
List<Object> rows = table.tableRows;