PHP Classes


Recommend this page to a friend!
  Classes of Joubert RedRat   PHP AJAX Table   Download  
Role: Documentation
Content type: text/markdown
Description: Example script
Class: PHP AJAX Table
Load HTML tables dynamically using AJAX
Author: By
Last change:
Date: 7 years ago
Size: 2,002 bytes


Class file image Download


AjaxTable is separated in two steps, configuration for build table and response after ajax request.


For configuration, is required to instanciate Conf to put all configuration, as below:

$Conf = new VectorDev\AjaxTable\Conf(base_url(['user', 'ajax-list']));

Conf will store all the information to generate a json for js lib

To create columns for your table, you will need to instanciate Column with information that you need to display.

$ColumnName = new VectorDev\AjaxTable\Column('username', 'Username');
$ColumnEmail = new VectorDev\AjaxTable\Column('email', 'E-mail');
$ColumnAge = new VectorDev\AjaxTable\Column('age', 'Age');

Column will store all the information about your table column.

After this, you need to add Column to your configuration.


To finish, you will build json configuration for AjaxTable js lib.

        $('#table').ajaxTable(<?php echo $Conf->getJson(); ?>);

And done, your table is now configurated to work as ajaxtable to request and print data.


For response, is required to work with Response, Row and Cell classes to get request, work with data and response to view.

$Response = new VectorDev\AjaxTable\Response();

$limit = $Response->getLimitForSql(); // AjaxTable automatic build array for your use directly in your query
$order = $Response->getOrderByForSql(); // AjaxTable automatic build array with order by too

foreach($all_data as $data) {
	$CellUsername = new VectorDev\AjaxTable\Cell($data['user_username']);
	$CellEmail = new VectorDev\AjaxTable\Cell($data['user_mail']);
	$CellAge = new VectorDev\AjaxTable\Cell($data['user_age']);
	$Row = new VectorDev\AjaxTable\Row($CellUsername, $CellEmail, $CellAge);