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.

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});

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.

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

ParameterTypeDescription
labelStringThe display text for the column header.
fieldNameStringThe field name to map data from rows to this column.
typeStringThe 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

Example

apex
instance.addColumn('My Label', 'myName', 'value');
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

ParameterTypeDescription
labelStringThe display text for the column header.
fieldNameStringThe field name to map data from rows to this column.
typeStringThe data type of the column (e.g., 'text', 'number').
sortableBooleanA Boolean indicating if the column should support sorting. @link https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/documentation

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

ParameterTypeDescription
anObjectObjectThe data object representing a row to be added to the table.

Example

apex
instance.addRow('value');

Properties

PropertyDescription
global List<DTO_BaseTable.DTO_Column> columnsRetrieves the list of columns defined in the table.
global List<Object> rowsRetrieves all rows added to the table.

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.

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.

Fields

FieldDescription
global transient List<DTO_BaseTable.DTO_Column> tableColumnsList of table columns within this table
global transient List<Object> tableRowsList of table rows within this table

tableColumns

apex
global transient List<DTO_BaseTable.DTO_Column> tableColumns

Type: List

List of table columns within this table

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

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;

Inner Classes

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