j ai suivi le tuto de swe DataTablesBundle sur le site de github liien
j'arrive pas a voir le resultat de datatables dans mon twig la page web reste en chargement voila mon code:
defaultBundle:
ActeurDataTable qui etai generer avec la commande :php app/console sg:datatable:generate datatbBundle:Acteur --bootstrap3
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 <?php namespace datatbBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use MyAppFilmothequeBundle\Datatables\ActeurDatatable; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; class DefaultController extends Controller { /** * @Route("/", name="post_index") * @Method("GET") */ public function indexAction() { $datatable = $this->get('app.datatable.post'); die($datatable); $datatable->buildDatatable(); return $this->render('datatbBunble:index.html.twig', array( 'datatable' => $datatable, )); } /** * @Route("/results", name="post_results") */ public function indexResultsAction() { $datatable = $this->get('app.datatable.post'); $datatable->buildDatatable(); $query = $this->get('sg_datatables.query')->getQueryFrom($datatable); return $query->getResponse(); } }
service.yml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149 <?php namespace datatbBundle\Datatables; use Sg\DatatablesBundle\Datatable\View\AbstractDatatableView; use Sg\DatatablesBundle\Datatable\View\Style; /** * Class ActeurDatatable * * @package datatbBundle\Datatables */ class ActeurDatatable extends AbstractDatatableView { /** * {@inheritdoc} */ public function buildDatatable(array $options = array()) { $this->topActions->set(array( 'start_html' => '<div class="row"><div class="col-sm-3">', 'end_html' => '<hr></div></div>', 'actions' => array( array( 'route' => $this->router->generate('acteur_new'), 'label' => $this->translator->trans('datatables.actions.new'), 'icon' => 'glyphicon glyphicon-plus', 'attributes' => array( 'rel' => 'tooltip', 'title' => $this->translator->trans('datatables.actions.new'), 'class' => 'btn btn-primary', 'role' => 'button' ), ) ) )); $this->features->set(array( 'auto_width' => true, 'defer_render' => false, 'info' => true, 'jquery_ui' => false, 'length_change' => true, 'ordering' => true, 'paging' => true, 'processing' => true, 'scroll_x' => false, 'scroll_y' => '', 'searching' => true, 'state_save' => false, 'delay' => 0, 'extensions' => array() )); $this->ajax->set(array( 'url' => $this->router->generate('acteur_results'), 'type' => 'GET' )); $this->options->set(array( 'display_start' => 0, 'defer_loading' => -1, 'dom' => 'lfrtip', 'length_menu' => array(10, 25, 50, 100), 'order_classes' => true, 'order' => array(array(0, 'asc')), 'order_multi' => true, 'page_length' => 10, 'paging_type' => Style::FULL_NUMBERS_PAGINATION, 'renderer' => '', 'scroll_collapse' => false, 'search_delay' => 0, 'state_duration' => 7200, 'stripe_classes' => array(), 'class' => Style::BOOTSTRAP_3_STYLE, 'individual_filtering' => false, 'individual_filtering_position' => 'head', 'use_integration_options' => true, 'force_dom' => false )); $this->columnBuilder ->add('id', 'column', array( 'title' => 'Id', )) ->add('nom', 'column', array( 'title' => 'Nom', )) ->add('prenom', 'column', array( 'title' => 'Prenom', )) ->add('dateNaissance', 'column', array( 'title' => 'DateNaissance', )) ->add('sexe', 'column', array( 'title' => 'Sexe', )) ->add(null, 'action', array( 'title' => $this->translator->trans('datatables.actions.title'), 'actions' => array( array( 'route' => 'acteur_show', 'route_parameters' => array( 'id' => 'id' ), 'label' => $this->translator->trans('datatables.actions.show'), 'icon' => 'glyphicon glyphicon-eye-open', 'attributes' => array( 'rel' => 'tooltip', 'title' => $this->translator->trans('datatables.actions.show'), 'class' => 'btn btn-primary btn-xs', 'role' => 'button' ), ), array( 'route' => 'acteur_edit', 'route_parameters' => array( 'id' => 'id' ), 'label' => $this->translator->trans('datatables.actions.edit'), 'icon' => 'glyphicon glyphicon-edit', 'attributes' => array( 'rel' => 'tooltip', 'title' => $this->translator->trans('datatables.actions.edit'), 'class' => 'btn btn-primary btn-xs', 'role' => 'button' ), ) ) )) ; } /** * {@inheritdoc} */ public function getEntity() { return 'datatbBundle\Entity\Acteur'; } /** * {@inheritdoc} */ public function getName() { return 'acteur_datatable'; } }
Acteur Entitie:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 app.datatable.post: class: datatbBundle\Datatables\ActeurDatatable parent: sg_datatables.datatable.abstract
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150 <?php /** * Created by PhpStorm. * User: STG * Date: 22/08/2016 * Time: 13:04 */ namespace datatbBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity */ class Acteur { /** * @ORM\GeneratedValue * @ORM\Id * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string",length=255) * @Assert\NotBlank() */ private $nom; /** * @ORM\Column(type="string",length=255) * @Assert\NotBlank() */ private $prenom; /** * @ORM\Column(type="date") * @Assert\NotBlank() */ private $dateNaissance; /** * @ORM\Column(type="string",length=1) * @Assert\NotBlank() * @Assert\Choice(choices = {"M", "F"}) */ private $sexe; /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set nom * * @param string $nom * @return Acteur */ public function setNom($nom) { $this->nom = $nom; return $this; } /** * Get nom * * @return string */ public function getNom() { return $this->nom; } /** * Set prenom * * @param string $prenom * @return Acteur */ public function setPrenom($prenom) { $this->prenom = $prenom; return $this; } /** * Get prenom * * @return string */ public function getPrenom() { return $this->prenom; } /** * Set dateNaissance * * @param \DateTime $dateNaissance * @return Acteur */ public function setDateNaissance($dateNaissance) { $this->dateNaissance = $dateNaissance; return $this; } /** * Get dateNaissance * * @return \DateTime */ public function getDateNaissance() { return $this->dateNaissance; } /** * Set sexe * * @param string $sexe * @return Acteur */ public function setSexe($sexe) { $this->sexe = $sexe; return $this; } /** * Get sexe * * @return string */ public function getSexe() { return $this->sexe; } }
Partager