1. Go to this page and download the library: Download kilik/table library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kilik / table example snippets
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
// ...
new \Kilik\TableBundle\KilikTableBundle(),
];
// ...
}
}
$massAction = new MassAction('delete', 'Delete selected items');
// First parameter 'delete' must not contain space or special characters (identifier)
$massAction->setAction('path/to/my-form-action.php');
$table = (new Table())
// ...
->addMassAction($massAction)
// ...
// Then your form action, you can grab selected rows as entities
$selectedEntities = $this->get('kilik_table')
->getSelectedRows($request, $this->getTable());
foreach ($selectedEntities as $entity) {
// ...
$entity->doSomething();
// ...
}
// Disable using javascript local storage form filters
public function getTable()
{
return (new Table())->setSkipLoadFilterFromLocalStorage(true);
}
// On ajax action : store filters data
public function _list(Request $request)
{
$table = $this->getTable();
$response = $this->get('kilik_table')->handleRequest($table, $request);
// Handle request for table form
$this->kilik->createFormView($table);
$table->getForm()->handleRequest($request);
$data = $table->getForm()->getData();
$this->filterStorage->store($data); // Use your custom storage
return $response;
}
// On default action
public function list()
{
$table = $this->getTable();
$data = $this->filterStorage->get();
return $this->render('list.html.twig', array(
'table' => $this->kilik->createFormView($table, $data),
));
}
$table
->addColumn(
(new Column())
->setSort(['u.createdAt' => 'asc'])
->setDisplayFormat(Column::FORMAT_DATE)
->setDisplayFormatParams('d/m/Y H:i:s') // or for example FilterDate::INPUT_FORMAT_LITTLE_ENDIAN
->setFilter((new FilterDate())
->setName('u_createdAt')
->setField('u.createdAt')
->setInputFormat(FilterDate::INPUT_FORMAT_LITTLE_ENDIAN)
)
)
;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.