-
Notifications
You must be signed in to change notification settings - Fork 59
Installation and Configuration
Clone this project into your ./vendor/
directory.
Add this project in your composer.json:
{
...
"require": {
"zendframework/zendframework": "2.3.*",
"dudapiotr/zftable": "dev-master"
}
}
Optional if You want to use Doctrine or AssetManager functionality add below code
{
...
"require": {
"zendframework/zendframework": "2.3.*",
"dudapiotr/zftable": "dev-master",
"doctrine/doctrine-orm-module": "0.*",
"rwoverdijk/assetmanager" : "dev-master"
}
}
Enabling it in your application.config.php
file.
<?php
return array(
'modules' => array(
// ...
'ZfTable',
),
// ...
);
// ...
-
Look at ..vendor\dudapiotr\zftable\src\ZfTable\Public folder. There are css, js and img folder. Most of them are optional, but if you install this module first time please copy all files to Your Public folder (zfproject/public/)
-
Add all required scripts (css nad js ) to Your layout - My configuration looks like that:
<!-- CSS SCRIPTS -->
<?php
echo $this->headLink(array(
'rel' => 'shortcut icon',
'type' => 'image/vnd.microsoft.icon',
'href' => $this->basePath() . '/img/favicon.ico'
))
->prependStylesheet($this->basePath() . '/css/bootstrap-3.0.0/bootstrap.min.css')
->prependStylesheet($this->basePath() . '/css/style.css')
->prependStylesheet($this->basePath() . '/css/zf-table/zf-table.css')
//->prependStylesheet($this->basePath() . '/css/bootstrap-2.2.2/DT_bootstrap.css')
//->prependStylesheet($this->basePath() . '/css/bootstrap-2.2.2/bootstrap-responsive.min.css')
//->prependStylesheet($this->basePath() . '/css/bootstrap-2.2.2/bootstrap.min.css')
?>
<!-- JS SCRIPTS -->
<?php
echo $this->headScript()->appendFile($this->basePath() . '/js/jquery.min.js')
->appendFile($this->basePath() . '/js/jquery.dataTables.min.js')
->appendFile($this->basePath() . '/js/zf-table.js')
->appendFile($this->basePath() . '/js/DT_bootstrap_3.js')
//->appendFile($this->basePath() . '/js/DT_bootstrap_2.js')
?>
"//" for enabling and disabling funcionality like switching between Bootstrap 2 and 3
ZfTable needed set up database configuration, if You want to get data from it. (My configuration of global.php)
<?php
return array(
'db' => array(
'driver' => 'Pdo',
'username' => 'root',
'dsn' => 'mysql:dbname=tabeleczka;host=localhost',
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
),
),
'service_manager' => array(
'factories' => array(
'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory',
),
),
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'root',
'password' => '',
'dbname' => 'tabeleczka',
)
)
)
),
);
2.4. If You want to see how it works - example tables, in ZfTable/data/customer.sql there are sample data.
2.5 Run sample table (http://your-project/table/base). You should see full working table.
Controller is located in ZfTable/src/ZfTable/Controller/TableController
/**
* ********* Base *******************
* ***********************************
*/
public function baseAction()
{
}
public function ajaxBaseAction()
{
$table = new TableExample\Base();
$table->setAdapter($this->getDbAdapter())
->setSource($this->getSource())
->setParamAdapter($this->getRequest()->getPost())
;
return $this->htmlResponse($table->render());
}
View is located in ZfTable/view/zf-table/table/base.phtml
<div id="tableContainer"></div>
*
*
*
<script>
$("#tableContainer").zfTable('/table/ajax-base');
</script>
Table class is located in ZfTable/src/ZfTable/Example/TableExample/Base.php
- By default is called url like below, so you have to set Your project correctly. Look at that:
<script>
$("#tableContainer").zfTable('/table/ajax-base');
</script>
Basic configuration : http://dudapiotr.eu/table/changes
ToDo