Open stijnhau opened 10 years ago
Hi, A small install instruction you have here: https://github.com/dudapiotr/ZfTable#installation
But, today I'm going to put a more detailed.
That is just the simple adding to composer and enableling it. I mean miore like the step after that how do we implement those demo's.
Here you have more detaild instruction:
https://github.com/dudapiotr/ZfTable/wiki/Installation-and-Configuration
I have a problem with showing the datatables. I don't get any error, but the progressbar just keeps running
What might cause this problem?
Hi, Please paste here what you get from ajax response. Please use ajax debugger like firebug or chrome development tool.
This is what I get from Chrome tools: Remote Address:::1:80 Request URL:http://localhost/demo/public/js/jquery.min.map Request Method:GET Status Code:404 Not Found
Firebug: POST http://localhost/table/ajax-base 404 Not Found 1ms jquery.min.js (regel 3) HeadersPostAntwoordHTMLCookies
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
The requested URL /table/ajax-base was not found on this server.
"NetworkError: 404 Not Found - http://localhost/demo/public/img/zf2-logo.png" zf2-logo.png "NetworkError: 404 Not Found - http://localhost/table/ajax-base" ajax-base
Probably you don't set Your VirutalHost in Apache Web Server. Look at that:
Currently if You want to see full working table You have to change action url in base.phtml script:
$("#tableContainer").zfTable('/table/ajax-base') to $("#tableContainer").zfTable('http://localhost/YOUR-PROJECT/public/table/ajax-base')
My virtual host settings are correctly, the skeletonapplication is working fine!
<VirtualHost *:8888>
ServerName demo.localhost
DocumentRoot /Applications/MAMP/htdocs/demo/public/
SetEnv APPLICATION_ENV "development"
<Directory /Applications/MAMP/htdocs/demo/public/>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from All
$("#tableContainer").zfTable('http://localhost/demo/public/table/ajax-base') does not work $("#tableContainer").zfTable('localhost/demo/public/table/ajax-base') does not work $("#tableContainer").zfTable('demo/public/table/ajax-base') does not work $("#tableContainer").zfTable('public/table/ajax-base') does not work
I see that http://localhost/demo/public/js/jquery.min.map also does not exist, but this file is not included in github repository. Is it possible this is generating the error?
Ok, If Your serverName is demo.localhost - it's ok (but problem is that application try to call wrong url like
http://localhost/table/ajax-base. It should try to call http://demo.localhost/table/ajax-base
)
What url addres do You have in Your browser ?
My url in browser is: http://localhost/demo/public/table/base
And for skeletonapplication: http://localhost/demo/public/album/
Ok, Please try this url browser (it's correct url for Your application):
http://demo.localhost/table/base
Make sure that you update your /etc/hosts or c:\windows\system32\drivers\etc\hosts file so that demo.localhost is mapped to 127.0.0.1. The website can then be accessed using http://demo.localhost
127.0.0.1 demo.localhost
And the other way is change base.phtml file: $("#tableContainer").zfTable('http://localhost/demo/public/table/ajax-base')
And another one it can be problem with Your route located in module/Application/config/module.config
Please past content of this file
OK, done! Now I'm getting another error:
'Strict Standards: Declaration of ZfTable\Example\TableExample\Base::initFilters() should be compatible with ZfTable\AbstractTable::initFilters($query) in /Applications/MAMP/htdocs/demo/vendor/dudapiotr/zftable/src/ZfTable/Example/TableExample/Base.php on line 15'
File: '/Applications/MAMP/htdocs/demo/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver/Pdo/Statement.php:245'
Message: 'Statement could not be executed (42S02 - 1146 - Table 'demo.customer' doesn't exist)'
This is content from module.config
'''php namespace Application;
use Zend\Mvc\ModuleRouteListener; use Zend\Mvc\MvcEvent;
class Module { public function onBootstrap(MvcEvent $e) { $eventManager = $e->getApplication()->getEventManager(); $moduleRouteListener = new ModuleRouteListener(); $moduleRouteListener->attach($eventManager); }
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
}'''
Ad1. String - Have You got newest version ? Becouse Base.php should have code like below
protected function initFilters(\Zend\Db\Sql\Select $query)
{
}
Ad2. In You database demo have You create table like customer ? (Look at ZfTable/data/customer.sql)
CREATE TABLE IF NOT EXISTS `customer` (
`idcustomer` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) DEFAULT NULL,
`surname` varchar(100) DEFAULT NULL,
`age` int(11) NOT NULL DEFAULT '10',
`city` varchar(100) DEFAULT NULL,
`street` varchar(100) DEFAULT NULL,
`active` tinyint(1) NOT NULL DEFAULT '1',
`edit1` varchar(100) NOT NULL DEFAULT 'edit1',
`edit2` varchar(100) NOT NULL DEFAULT 'edit2',
PRIMARY KEY (`idcustomer`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=37 ;
--
-- Zrzut danych tabeli `customer`
--
INSERT INTO `customer` (`idcustomer`, `name`, `surname`, `age`, `city`, `street`, `active`, `edit1`, `edit2`) VALUES
(1, 'Jan', 'Janowski', 6, 'Warszawa', 'Obozowa', 0, 'edit1', 'edit2'),
(2, 'Krzysztof', 'Kowalski4', 77, 'Warszawa', 'Andersa', 1, 'edit1 test', 'edit2'),
(3, 'Adam', 'Adamski', 22, 'Sopot', 'Bartoka', 1, 'edit1', 'edit2'),
(4, 'Piotr', 'Piotrowski1', 55, 'Warszawa', 'Belgijska', 0, 'edit1', 'edit2 asbasd fa'),
(5, 'Wojciech', 'Wojciechowski', 22, 'Krakow', 'Dembiñskiego', 1, 'edit1', 'edit2'),
(6, 'Grzesiek', 'Grzeskowski', 88, 'Bialystok', 'Deotymy', 1, 'edit1', 'edit2'),
(7, 'Tomas', 'Tomasowski', 22, 'Gdansk', 'Dereniowa', 0, 'edit1', 'edit2'),
(8, 'Zenek', 'Zenkowski', 99, 'Wroclaw', 'Grzesiuka', 1, 'edit1', 'edit2'),
(9, 'Wojciech', 'Wojciechowski', 33, 'Gdynia', 'Grzybowska', 1, 'edit1', 'edit2'),
(10, 'Adam', 'Janowski', 12, 'Warszawa', 'Jagmina', 0, 'edit1', 'edit2'),
(11, 'Grzesiek', 'Kowalski3', 10, 'Warszawa', 'Jakiela', 0, 'edit1', 'edit2'),
(12, 'Jan', 'Adamski', 2, 'Sopot', 'Kossaka', 1, 'edit1', 'edit2'),
(13, 'Krzysztof', 'Piotrowski', 77, 'Warszawa', 'Koszykowa', 1, 'edit1', 'edit2'),
(14, 'Piotr', 'Wojciechowski', 36, 'Krakow', 'Lipowczana', 0, 'edit1', 'edit2'),
(15, 'Tomas', 'Grzeskowski', 34, 'Bialystok', 'Lipska', 1, 'edit1', 'edit2'),
(16, 'Wojciech', 'Tomasowski', 52, 'Gdansk', 'Morskie Oko', 1, 'edit1', 'edit2'),
(17, 'Wojciech', 'Zenkowski', 17, 'Wroclaw', 'Mostowa', 0, 'edit1', 'edit2'),
(18, 'Zenek', 'Wojciechowski', 44, 'Gdynia', 'Motorowa', 0, 'edit1', 'edit2'),
(19, 'Jan', 'Adamski1', 22, 'Warszawa', 'Obozowa', 0, 'edit1', 'edit2'),
(20, 'Krzysztof', 'Adamski2', 77, 'Wroclaw', 'Motorowa', 1, 'edit1', 'edit2'),
(21, 'Adam', 'Grzeskowski1', 23, 'Wroclaw', 'Mostowa', 1, 'edit1', 'edit2'),
(22, 'Piotr', 'Grzeskowski2', 28, 'Warszawa', 'Morskie Oko', 0, 'edit1', 'edit2'),
(23, 'Wojciech', 'Janowski', 23, 'Warszawa', 'Lipska', 1, 'edit1', 'edit2'),
(24, 'Grzesiek', 'Janowski2', 32, 'Warszawa', 'Lipowczana', 1, 'edit1', 'edit2'),
(25, 'Tomas', 'Kowalski', 27, 'Warszawa', 'Koszykowa', 0, 'edit1', 'edit2'),
(26, 'Zenek', 'Kowalski2', 38, 'Warszawa', 'Kossaka', 1, 'edit1', 'edit2'),
(27, 'Wojciech', 'Piotrowski2', 39, 'Sopot', 'Jakiela', 1, 'edit1', 'edit2'),
(28, 'Adam', 'Piotrowski3', 13, 'Sopot', 'Jagmina', 0, 'edit1', 'edit2'),
(29, 'Grzesiek', 'Tusk', 14, 'Krakow', 'Grzybowska', 0, 'edit1', 'edit2'),
(30, 'Jan', 'Tomasowski1', 16, 'Krakow', 'Grzesiuka', 1, 'edit1', 'edit2'),
(31, 'Krzysztof', 'Wojciechowski', 0, 'Gdynia', 'Dereniowa', 1, 'edit1', 'edit2'),
(32, 'Piotr', 'Nowak', 0, 'Gdynia', 'Deotymy', 0, 'edit1', 'edit2'),
(33, 'Tomas', 'Danielowski', 0, 'Gdansk', 'Dembiñskiego', 1, 'edit1', 'edit2'),
(34, 'Wojciech', 'Wojciechowski', 0, 'Gdansk', 'Belgijska', 1, 'edit1', 'edit2'),
(35, 'Wojciech', 'Zenkowski4', 0, 'Bialystok', 'Bartoka', 0, 'edit1', 'edit2'),
(36, 'Zenek', 'Zenkowski2', 0, 'Bialystok', 'Andersa', 0, 'edit1', 'edit2');
CREATE TABLE IF NOT EXISTS `product` (
`id` int(11) NOT NULL DEFAULT '0',
`customer_id` int(11) DEFAULT NULL,
`product` varchar(100) COLLATE utf8_polish_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;
--
-- Zrzut danych tabeli `product`
--
INSERT INTO `product` (`id`, `customer_id`, `product`) VALUES
(1, 1, 'test'),
(2, 2, 'test2'),
(3, 3, 'atest3'),
(4, 4, 'test4'),
(5, 5, 'btest5');
Ad1. String - Have You got newest version ? Becouse Base.php should have code like below
protected function initFilters(\Zend\Db\Sql\Select $query)
{
}
Yes, I have this version I've run down all files again, and now the table is working but one error left:
Strict Standards: Declaration of ZfTable\Example\TableExample\Base::initFilters() should be compatible with ZfTable\AbstractTable::initFilters($query) in /Applications/MAMP/htdocs/demo/vendor/dudapiotr/zftable/src/ZfTable/Example/TableExample/Base.php on line 15
You have a right - in code there is a strict standard problem.
You have to change this one
protected function initFilters(\Zend\Db\Sql\Select $query)
{
}
to
protected function initFilters( $query)
{
}
I've pushed changes to repo (newest commit).
I have installed the module Correctly and it work good. But how can i use this module in my other module in application?
If You want to create table class in other places only one thing to do is create Your Table class and extends AbstractTable.
use \ZfTable\AbstractTable;
namespace YourModule\YourNamespace
use \ZfTable\AbstractTable;
class YourTable extends AbstractTable
{
protected $config = array(
'name' => 'Filtering by column',
'showPagination' => true,
'showQuickSearch' => false,
'showItemPerPage' => true,
'itemCountPerPage' => 10,
'showColumnFilters' => true,
);;
```php
Everything is working with namespaces.
Can you please tel me what i can put in a controller to use your module. For example i m using the zf-tutorial album module of Akrabat i want to get album from database, ui have these code:
namespace Album\Controller; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; use Album\Model\Album; use Album\Form\AlbumForm; class AlbumController extends AbstractActionController { protected $albumTable; public function indexAction() { return new ViewModel(array( 'albums' => $this->getAlbumTable()->fetchAll(), )); } . . . . }
namespace Album\Model; use Zend\Db\TableGateway\AbstractTableGateway; use Zend\Db\Adapter\Adapter; use Zend\Db\ResultSet\ResultSet; class AlbumTable extends AbstractTableGateway { protected $table = 'album'; public function __construct(Adapter $adapter) { $this->adapter = $adapter; $this->resultSetPrototype = new ResultSet(); $this->resultSetPrototype->setArrayObjectPrototype(new Album()); $this->initialize(); } public function fetchAll() { $resultSet = $this->select(); return $resultSet; } . . . . }
Kan je give an example with zf2 Albumtutorial, how to implement your module
Hi there.
I'm trying to do a table with doctrine and i need to render date time elements
so i get a error every time i try to do this:
$this->getHeader('createdStamp')->getCell()->addDecorator('closure', array( 'closure' => function($context, $record){ return $record->createdStamp->format("d/m/Y"); } ));
anyone has a tip on this ?
thanks
Please write error You get....
Please try to change clousure to callable (last time decorator name has been changed)
I have installed the module Correctly and it work good. But how can i use this module in my other module in application?
It's pretty simple: all you need to do is call Your class with proper namespace. Look at that:
It is for me not clear. which class? I want to test it in albumcontroller: class AlbumController extends AbstractActionController { }
how can i call your module
How do we use this mdoule?
What dio we need to extend? add data to?
What dio we need to place in the view script?
Kind regards