User Tools

Site Tools


table_class

This is an old revision of the document!


Table class

Table is a PHP wrapper for the Tabulator javascript library, based of the Component class.

A basic table

The most basic table is created like:

$table = new Table();
// The setTabulatorOption function is used to pass options to the javascript tabulator function.
$table->setTabulatorOption('ajaxUrl', '/url-to-fetch-data');
$table->setTabulatorOption('columns', array(some column data));
// This renders the necessary html 
$table->render();

Datarecord convenience

The easiest way to work with Datarecord is using the DatarecordEditComplex class, but to build a custom way to interact with data records, it can still be done like this:

index.php
$table = new Table();
$table->setTabulatorOption('ajaxUrl', 'data_source.php');
$table->buildColumnsFromDatarecord(DATARECORD CLASS NAME);
$table->render();
data.php
// Get all data
$filter = new Platform\Filter(DATARECORD CLASS NAME);
$collection = $filter->execute();
 
$result = Table::getDataFromCollection($collection);
 
header('Content-type: text/json');
echo json_encode($result);
table_class.1596803651.txt.gz · Last modified: 2020/08/07 12:34 by sahl

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki