Craft Tablecloth
  • What is Tablecloth?
  • Installation
  • Table Definition
    • Data Source
    • Columns
    • Options
    • General Settings
    • Advanced
  • Table Rendering
    • Default Table
    • Templates
      • Table Templates
        • Cards Layout Example
      • Field Type Templates
      • Specific Field Templates
      • Child Rows
  • Programmatic Interaction
    • Interacting with The Table
    • Events
    • Methods
  • Localization
  • Contact Us
Powered by GitBook
On this page
  1. Programmatic Interaction

Interacting with The Table

PreviousChild RowsNextEvents

Last updated 3 years ago

Each data table exposes a global window-level object that can be used to listen for incoming events in order to receive data from the table, or to emit outbound events in order to send instructions to the table.

The global variable name follows the Tablecloth_{handle} convention. So if you have table with an entries handle, you will find a window.Tablecloth_entries object available.

The object consists of two methods:

1. .on() for listening for incoming events.

E.g to listen for when initial table load was completed:

window.Tablecloth_entries.on('init.loaded', (data) => {
    // Do Something
})

A complete list of events can be found on the page.

2. .emit() for sending instructions to the table.

E.g to go to page 2:

window.Tablecloth_entries.emit('paginate', 2)

A complete list of methods can be found on the page.

Events
Methods