2017 © Pedro PelĂĄez
 

symfony-bundle datatablebundle

Symfony DataTableBundle

image

zuni/datatablebundle

Symfony DataTableBundle

  • Thursday, March 27, 2014
  • by zunitec
  • Repository
  • 5 Watchers
  • 0 Stars
  • 192 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Data Table PHP

Exmplo de uso

Controlador

/** * * @Route("/grid/ajax", name="cidade_grid") * @Secure(roles="ROLE_CIDADE_SHOW") */ public function gridAction(Request $request) { $dataTable = $this->createDataTable($request);, (*1)

$dataTable
        ->addColumn('id')
        ->addColumn('nome')
        ->addColumn('estado.nome')
        ->addColumnAction($this->getDataTableActionsDefault())
;

$dataTable->setDqlPart('{estado.nome} = :estadoNome');
$dataTable->setDqlParam(array('estadoNome' => 'sc'));


return $this->getDataTableResponse($dataTable);

}, (*2)

Index

{{ "cidade.id"|trans }} {{ "cidade.nome"|trans }} {{ "estado.titulo"|trans }} {{"grid.acoes"|trans}}

MĂ©todos requeridos no controlador Super

/** * * Create new DataTable for response json * * @param \Symfony\Component\HttpFoundation\Request $request * @param string $condition DQL Contidion * @param arrray $paramCondition * @param type $entity * @return \Zuni\DataTableBundle\Entity\DataTable */ protected function createDataTable(Request $request, $condition = "", array $paramCondition = array(), $entity = null) { $entity = $entity ? $entity : $this->getNameEntity()." AS e";, (*3)

return new \Zuni\DataTableBundle\Entity\DataTable($request, $this->get("templating"), $this->getTwigLoaderString(), $entity);

}, (*4)

/** * * Create Data Table Response * * @param \Zuni\DataTableBundle\Entity\DataTable $dataTable * @return \Symfony\Component\HttpFoundation\JsonResponse */ protected function getDataTableResponse(\Zuni\DataTableBundle\Entity\DataTable $dataTable, $collectionsEntity = null ) { $arrayData = $dataTable->getData($this->getDoctrine()->getManager(), $collectionsEntity);, (*5)

return new JsonResponse($arrayData);

}, (*6)

/** * * Clona e modifica o twig do symfony para renderizar strings * * @return \Symfony\Bridge\Twig\TwigEngine */ protected function getTwigLoaderString() { $twigLoaderString = clone $this->get('twig'); $twigLoaderString->setLoader(new Twig_Loader_String());, (*7)

return $twigLoaderString;

}, (*8)

/** * * Retorna as açÔes padrão da entidade * * @todo Mudar as açÔes da DataTable para uma classe do bundle * @return array */ protected function getDataTableActionsDefault() { $entity = $this->getAliasEntity(); $entityUpperCase = strtoupper($entity);, (*9)

return array(
    'show' => array(
        'route' => $entity.'_show', 'role' => "ROLE_{$entityUpperCase}_SHOW"
    ),
    'edit' => array(
        'route' => $entity.'_edit', 'role' => "ROLE_{$entityUpperCase}_EDIT"
    ),
    'delete' => array(
        'route' => $entity.'_delete_ajax', 'role' => "ROLE_{$entityUpperCase}_EDIT"
    ),
);

}, (*10)

The Versions

27/03 2014

dev-master

9999999-dev https://github.com/zunitec/DataTableBundle

Symfony DataTableBundle

  Sources   Download

MIT

The Requires

 

The Development Requires

table datatable