1. Go to this page and download the library: Download domenik88/grid-bundle 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/ */
domenik88 / grid-bundle example snippets
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Dtc\GridBundle\Annotation as Grid;
/**
* Class User
* @Grid\Grid
* @ORM\Entity
* @package App\Entity
*/
class User {
//...
}
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Dtc\GridBundle\Annotation as Grid;
/**
* Class User
* @Grid\Grid(actions={@Grid\ShowAction(), @Grid\DeleteAction(), @Grid\Action(label="Custom",buttonClass="btn-info",onclick="alert('custom-action')")})
* @ORM\Entity
* @package App\Entity
*/
class User {
//...
}
/**
* List jobs in system by default.
*
* @Route("/jobs/")
*/
public function jobsAction()
{
$rendererFactory = $this->get('dtc_grid.renderer.factory');
$renderer = $rendererFactory->create('datatables');
$gridSource = $this->get('dtc_grid.manager.source')->get('Dtc\\QueueBundle\\Documents\\Job');
$renderer->bind($gridSource);
$params = $renderer->getParams();
$renderer2 = $rendererFactory->create('datatables');
$gridSource2 = $this->get('dtc_grid.manager.source')->get('Dtc\\QueueBundle\\Documents\\JobArchive');
$renderer2->bind($gridSource2);
$params2 = $renderer2->getParams();
$params['archive_grid'] = $params2['dtc_grid'];
return $this->render('@DtcQueue/Queue/jobs.html.twig', $params);
}
/**
* List jobs in system by default.
*
* @Route("/jobs/")
*/
public function jobsAction()
{
$rendererFactory = $this->get('dtc_grid.renderer.factory');
$renderer = $rendererFactory->create('jq_grid'); // NOTE THE DIFFERENT GRID TYPE
$gridSource = $this->get('dtc_grid.manager.source')->get('Dtc\\QueueBundle\\Documents\\Job');
$renderer->bind($gridSource);
$params = $renderer->getParams();
$renderer2 = $rendererFactory->create('datatables');
$gridSource2 = $this->get('dtc_grid.manager.source')->get('Dtc\\QueueBundle\\Documents\\JobArchive');
$renderer2->bind($gridSource2);
$params2 = $renderer2->getParams();
$params['archive_grid'] = $params2['dtc_grid'];
return $this->render('@DtcQueue/Queue/jobs.html.twig', $params);
}
/**
* @Route("/users_custom", name="app_grid_users_custom")
*/
public function usersCustomAction(Request $request) {
// other setup, etc.
// Assuming you have a variable called "$params"
$renderer = $this->get('dtc_grid.renderer.factory')->create('datatables'); // or whichever renderer you want to use
$gridSource = $this->get('dtc_grid.manager.source')->get('App:User');
$renderer->bind($gridSource);
$renderer->getParams($params); // This will add the grid-specific params (mainly 'grid', and the bootstrap urls)
// Alternatively you can do
// $dataGridParams = $renderer->getParams();
// $myParams['my_grid'] = $dataGridParams['dtc_grid'];
// render your page
return $this->render('@App/Something/somepage.html.twig', $params);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.