In some situation, we cannot use views to generate table output as per the business requirements.

In this situation, we need to write custom module to display the table records.

Ajax Datatables is a javascript API to render the datatables by passing the customized array data generated by any other custom module.

This module always useful for developers, who will create a customized array data to display the datatables.

This module also support dropdown filter to filter the table records. To support dropdown filter, we need to include all the dropdown fields with in wrapper ID and mention the wrapper ID in the 'filterwrapperID' argument as below

'filterwrapperID' => '#datatablefilter'

All the filter values available in the query parameter on each ajax callback function and based on the filter values we can write the code to filter the table records.

This module uses the datatables plugin.

You can find more information about this plugin in the below link,
- https://datatables.net

Usage :

This module also provides Example User List Block to describe how to implement the datatables using custom array data.

Don't forget to check the permission "Access Ajax Datatables User List" in the permission page for particular role to access the Datatables.

-> To render the datatables, please refer the block file included in this module.
-> To generate the custom array records, Please refer the Controller file included in this module.

POST Values
Some available POST values on ajax callback functions are,


// Pagination
$_POST['start'] - Row number
$_POST['length'] - Number of rows to display per page

// Sorting
$cIndex = $_POST['order'][0]['column'] - Index of the selected column.
$_POST['columns'][$cIndex]['data'] - Name of the selected column.
$_POST['order'][0]['dir'] - asc or desc.

// Search
$_POST['search']['value'] - Value entered for search.

REQUIREMENTS

This module requires no modules outside of Drupal core.

INSTALLATION

* Install the Ajax Datatables module as you would normally install a
contributed Drupal module. Visit https://www.drupal.org/node/1897420
for further information.

CONFIGURATION

This module does not require any configuration.

MAINTAINERS

Current maintainers:
Elavarasan R - https://www.drupal.org/user/1902634

Supporting organizations: 

Project information

  • caution Seeking new maintainer
    The current maintainers are looking for new people to take ownership.
  • Created by elavarasan r on , updated
  • shieldStable releases for this project are covered by the security advisory policy.
    Look for the shield icon below.

Releases