See demo: http://tapi-ozooner.rhcloud.com/ What can it do?
This module allows developers to expose drupal-style queries (db_select) as a pageable-sortable ajax table with as little coding as possible:
- Supports join queries*
- Supports filtering
- Supports editing, inserting and deleting data
Installation process is quite standard, however be sure to configure permissions according to your use-case. The permissions protect callback endpoints: Usage
This module is for developers only as it is meant to integrate into other modules. Simple usage:
-
Construct the query you want to expose:
db_set_active(); $query = db_select('tapi_demo') ->fields('tapi_demo',array('id','field1', 'field2', 'field3'));
-
Tell table API how to render the table:
$data = array(); $data['query'] = $query; $data['limit'] = 20; //Limit per page $data['sort'] = 'asc'; //Default sort order $data['order'] = 'id'; //Default sort column $data['page'] = 0; //Default start page
-
Pass $data object to render function to get back html:
$html = table_api_render($data)
-
Display the table in a form (or anywhere else):
$form['table_data'] = array( '#markup' => $html );
Adding new functionality in just one line:
$data['delete'] = 'id'; //delete on id condition
$data['editable'] = array('field1', 'field2'); //enables editing following fields
$data['update_cond'] = 'id'; //update on id contition
$data['insert'] = true; //enable insertion of new rows
Please refer to table_api_demo.module to see how filtering and callbacks are implemented.