Methods

List of methods to trigger using .emit()

  • filter: Filter by a given column. Receives an object with a column and query properties. You can use this to trigger filtering on the table from your own UI elements (which can either be external to the table, or embedded via a Table Template). E.g, say you have a dropdown field with a products handle. When the user selects a value you can trigger:

Tablecloth__entries.emit('filter',{
   column: 'products',
   query: 'samsung'
})

Tablecloth will handle the rest. If its a client table, the search will occur on the front-end. If it is a server table, a request will be sent with the relevant filter, and handled in the back-end.

An optional operand parameter can be added for numeric and date fields. E.g if you want to search for a number greater than 60:

Tablecloth__entries.emit('filter',{
   column: 'numericFieldHandle',
   query: 60,
   operand: '>'
})

Supported operands: <,<=,>,>=,LIKE

To search for a range of numbers or dates pass an array to the query property:

Tablecloth__entries.emit('filter',{
   column: 'dateFieldHandle',
   query: [new Date(2022,1,1), new Date(2022,1,31)]
})
  • filter.setAll: Set multiple filters at once. Same syntax as filter, except it accepts an array. E.g:

Tablecloth__entries.emit('filter.setAll',[
{
   column: 'dateFieldHandle',
   query: [new Date(2022,1,1), new Date(2022,1,31)]
},
{
   column: 'numericFieldHandle',
   query: 60,
   operand: '>'
}
])
  • filter.resetAll: Reset all filters (except for native free text filter)

  • filter.reset: resets (removes) a specific filter. Accepts column name. e.g emit('filter.reset','dateFieldHandle')

  • sort: Sorts by a given column. Accepts an object with a column and asc properties, the latter being a Boolean for "is ascending order?" .

  • paginate: Changes the page. Accepts a page number.

Last updated