Spanish Total.js
Slovenčina
Dokumentácia Pre AI agentov
Obsah

Extension reference

The browser events, the helpers of the record window and the server events that extensions use.

.md Web

Táto stránka ešte nie je preložená. Čítaš originál.

Na tejto stránke

Extensions use these events and helpers. Browser events are registered in the <script> part of an extension, server events in the <script total> part.

Entries of type event are functions that you register and Tables calls. Entries of type method are functions that Tables provides.

API

event

ON('detail', function(meta) {})

Runs in the browser each time a record window opens.
ParameterTypPopis
meta.table Object The settings of the table: id, name, columns and the others.
meta.columns Array The fields of the form. Push { type: 'custom', html: '...' } to add your own HTML.
meta.plugin Object The record window. Functions you add to it can be called from your HTML with class="exec" data-exec="?/name".
meta.response Object The record as read from the server.
meta.toolbar Array The buttons of the toolbar of the window.
meta.actions Array The items of the Actions menu of the window.

Use it to add fields or buttons to the detail of a record. Check meta.table.id to change only one table.

Add a note at the end of the orders
ON('detail', function(meta) {
	if (meta.table.id === 't118h7')
		meta.columns.push({ type: 'custom', html: '<p>Check the stock before you ship.</p>' });
});
event

ON('listing', function(meta) {})

Runs in the browser when the list of records of a table is prepared.
ParameterTypPopis
meta.table Object The settings of the table.
meta.columns Array The columns of the list.
meta.toolbar Array The buttons of the toolbar of the list.
meta.element jQuery The element of the list window.
meta.plugin Object The list window.
meta.links Array The tables that link to this table and where the user can create records.
meta.lists Array The tables that link to this table and that the user can read.

Use it to inspect or change the list before it is shown.

Log the columns of each list
ON('listing', function(meta) {
	console.log(meta.table.name, meta.columns.length);
});
event

ON('actions', function(meta) {})

Runs in the browser when a user opens the Actions menu of a list.
ParameterTypPopis
meta.actions Array The items of the menu.
meta.table Object The settings of the table.
meta.items Array The records on the current page.
meta.plugin Object The list window.

Use it to inspect or change the items of the menu before it is shown.

Log the number of items
ON('actions', function(meta) {
	console.log(meta.table.name, meta.actions.length);
});
method

meta.plugin.collect()

Returns the current values of the record window.

Available in the detail event. The object has the id, the name and each column under its ID. A relation column holds the ID of the linked record.

Read the amount of an order
let values = meta.plugin.collect();
console.log(values.x04);
method

meta.plugin.tapi(name, data, callback)

Calls a server action of Tables or of an extension.
ParameterTypPopis
name String The name of the action, for example Orders|hello.
data Object The input of the action.
callback Function function(response) with the answer of the action.

The call is made with the session of the signed-in user. The action needs a route such as route: '+API ?' to be callable from the browser.

Send the record to a server action
meta.plugin.tapi('Orders|hello', meta.plugin.collect(), function(response) {
	alert(response);
});
event

ON('@Data|save', function($) {})

Runs on the server each time an operation of Tables is called.
ParameterTypPopis
$.payload Object The input of the operation. For Data|save: tableid and data.
$.user Object The user or API token that called the operation.

Use the name of the operation after @, for example @Data|save for every saved record. $.payload is the input of the operation and $.user the user.

Log every saved order
ON('@Data|save', function($) {
	if ($.payload.tableid === 't118h7')
		console.log('Order saved by', $.user.name);
});
Vyrobené v Európe