Symfony2 - Doctrine2 - How can i use datatables ?

Symfony2 - Doctrine2 - How can i use datatables ?

elpadrinoelpadrino Posts: 20Questions: 1Answers: 0
edited October 2013 in General
Hello everyone,

I am trying to understand how it's possible to use datatables but i don't really understand.
I explain my problem :

config_dev.yml :

[code]
ali_datatable:
all:
action: false
search: false
js:
iDisplayLength: "10"
aLengthMenu: "[[5,10, 25, 50, -1], [5,10, 25, 50, 'All']]"
bJQueryUI: "false"

[/code]

statsController.php

[code]

/**
* set datatable configs
*
* @return \Ali\DatatableBundle\Util\Datatable
*/
private function _datatable() {
return $this->get('datatable')
->setEntity("TestCommerceBundle:StatsSage", "s")
->setFields(
array(
"CP" => 's.ctCodePostal', //
"_identifier_" => 's.cbMarq')
);
}

/**
* Grid action
* @return Response
*/
public function gridAction() {
return $this->_datatable()->execute(); // call the "execute" method in your grid action
}

public function indexAction() {

$this->_datatable();
return $this->render('TestCommerceBundle:Stats:index.html.twig');

}


[/code]

index.html.twig

[code]

{{ datatable({
'js' : {
'sAjaxSource' : path('Statistiques_grid')
}
})
}}

[/code]

EDIT :

1 - In index.html.twig , how can i receive and use datas from function "datatable" in StatsController.php ?
2 - Routing configuration

[code]
Statistiques:
pattern: /statistiquesCommerce
defaults: { _controller: TestCommerceBundle:Stats:index }

Statistiques_grid:
pattern: /statistiquesCommerce
defaults: { _controller: TestCommerceBundle:Stats:grid, _format: json}
requirements: { _format: (xml|json), _method: GET}
[/code]
Statistiques_grid searching function gridAction in StatsController, i force the parse with json.

-----------------------------------------------------------------------

EDIT 2 :

Problem resolved :

The pattern of "Statistiques_grid" was the same of "Statistiques", when i change pattern (for example add 1 after the link) it's working .

Replies

This discussion has been closed.