Home Reference Source
import TableBuilder from 'prg-editor/src/TableBuilder.js'
public class | source

TableBuilder

Table columns configurator

Constructor Summary

Public Constructor
public

constructor(translator: function(text: string))

Creates an instance of TableBuilder.

Method Summary

Public Methods
public

addAction(attr: string, name: string): ActionCellConfigurator

Adds action column to table

public

addRelationCell(attr: string, name: string): RelationCellConfigurator

Adds relation cell to table

public

addText(attr: string, name: string): TextCellConfigurator

Adds text column to table

public

getColsConfig(): Object

Returns the column configuration for {TableEditor}

Public Constructors

public constructor(translator: function(text: string)) source

Creates an instance of TableBuilder.

Params:

NameTypeAttributeDescription
translator function(text: string)
  • optional
  • default: null

Public Methods

public addAction(attr: string, name: string): ActionCellConfigurator source

Adds action column to table

Params:

NameTypeAttributeDescription
attr string

attribute name

name string

column name

Example:

tableBuilder.addAction('id', t('Remove'))
     .onClick((e, data) => this.tableEditor.delete(data))
     .condition((id, data) => acl.isAllowed('users.remove') && data.isAdministrable);

public addRelationCell(attr: string, name: string): RelationCellConfigurator source

Adds relation cell to table

Params:

NameTypeAttributeDescription
attr string

attribute name

name string

column name

Return:

RelationCellConfigurator

Example:

tableBuilder.addAction('userId', 'User name')
    .setResource('/api/users', 'name', 'id');

public addText(attr: string, name: string): TextCellConfigurator source

Adds text column to table

Params:

NameTypeAttributeDescription
attr string

attribute name

name string

column name

Example:

tableBuilder.addText('name', t('Name'))
     .orderBy()
     .orderByDefault();

public getColsConfig(): Object source

Returns the column configuration for {TableEditor}

Return:

Object