Skip to content

Repository files navigation

handsontable-php

handsontable-php is a PHP library that works as a wrapper for the Handsontable js library (https://handsontable.com/) and it was built with flexibility and maintainability in mind. It is a simple port of the JavaScript library to PHP, it was designed in a way to evolve in order that developer only needs to learn one API. This software is under AGPL-3.0 LICENCE.

Setup

The recommended way to install handsontable-php is through Composer. Just create a composer.json file and run the php composer.phar install command to install it:

{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/openSILEX/handsontable-php"
}
],
"require": {
"openSILEX/handsontable-php": "dev-master"
}
}

Usage

Configure examples :

After installing handsontable-php (through "Composer"), put the examples directory in a web server accessible path. Set the right vendor path in examples/config/configLibrairy.php

After you will be able to use example, try this :

(http://localhost/examples/array.php)

Simple case (array.php)

require_once'./config/configLibrairy.php';
useopenSILEX\handsontablePHP\adapter\HandsontableSimple;
/** * An example to load a PHP array in Handsontable */$hd = newHandsontableSimple();
$data = [
['', 'Tesla', 'Nissan', 'Toyota', 'Honda', 'Mazda', 'Ford'],
['2017', 10, 11, 12, 13, 15, 16],
['2018', 10, 11, 12, 13, 15, 16],
['2019', 10, 11, 12, 13, 15, 16],
['2020', 10, 11, 12, 13, 15, 16],
['2021', 10, 11, 12, 13, 15, 16]
];
$hd->setData($data);
?>
<html>
<head>
<?=$hd->loadJSLibraries(true); ?><?=$hd->loadCSSLibraries(); ?>
</head>
<br>
<h3><b>Simple array</b></h3>
<br>
<?=$hd->render() ?>
</html>
?>

Ajax case (autocompleteAjax.php)

<?phprequire_once'./config/configLibrairy.php';
useopenSILEX\handsontablePHP\adapter\HandsontableSimple;
useopenSILEX\handsontablePHP\classes\ColumnConfig;
useopenSILEX\handsontablePHP\classes\AjaxSourceColumn;
/** * An example to load a PHP array in Handsontable with an autocomplete column create from an ajax source */$hd = newHandsontableSimple();
$data = [
['', 'Tesla', 'Nissan', 'Toyota', 'Honda', 'Mazda', 'Ford'],
['2017', 10, 11, 12, 13, 15, 16],
['2018', 10, 11, 12, 13, 15, 16],
['2019', 10, 11, 12, 13, 15, 16],
['2020', 10, 11, 12, 13, 15, 16],
['2021', 10, 11, 12, 13, 15, 16]
];
$hd->setData($data);
$hd->setColumns([
newColumnConfig([
'data' => 0,
'type' => 'autocomplete',
'source' => newAjaxSourceColumn('ajax/array.php')
]),
newColumnConfig()
]);
?>
<html>
<br>
<h3><b>Autocomplete with ajax</b></h3>
<br>
<!--other way to load handsontable-->
<?=$hd->generateLibrairyContainerHTScript(true) ?>
</html>
?>

About

PHP wrapper for JavaScript Handsontable library

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages