내가의 일부 $ bin/vendor install
제외 하나를 사용하여 문서의 단계를 한 다음 GitHub의에 번들 AliDatatableBundle을 가져보기에에서 ID를 사용하여 "setDatatableId"와 행동에 데이터 테이블 ID를 설정 installation이기 때문에 Symfony2.6에서는이 작업을 수행 할 필요가 없습니다.Symfony2/DataTable을 번들 - 오류 :
/**
* set datatable configs
*
* @return \Ali\DatatableBundle\Util\Datatable
*/
private function _datatable()
{
$controller_instance = $this;
return $this->get('datatable')
->setDatatableId('batiments')
//->setEntity("MySpaceDatabaseBundle:Batiments", "b")
// replace "XXXMyBundle:Entity" by your entity
->setFields(
array(
"Nom" => 'b.nom',
// Declaration for fields:
"Reférence" => 'b.referencebatiment',
// "label" => "alias.field_attribute_for_dql"
"Ensembles" => 'b.ensembles',
"_identifier_" => 'b.id')
// you have to put the identifier field without label. Do not replace the "_identifier_"
)
//->setWhere(
// set your dql where statement
//'x.address = :address',
//array('address' => 'Paris')
//)
//->setOrder("x.created", "desc")
// it's also possible to set the default order
->setHasAction(true);
// you can disable action column from here by setting "false".
}
/**
* Grid action
* @return Response
*/
public function gridAction()
{
return $this->_datatable()->execute();
// call the "execute" method in your grid action
}
/**
* Lists all entities.
* @return Response
*/
public function indexAction()
{
$this->_datatable();
// call the datatable config initializer
return $this->render('MySpaceGestionPatrimoinesBundle:Batiments:indexBatiments.html.twig');
// replace "XXXMyBundle:Module:index.html.twig" by yours
}
: 여기
가 컨트롤러에 대한 코드입니다 : 내 컨트롤러의 기능, 내 나뭇 가지의 렌더링을 만들 때An exception has been thrown during the rendering of a template ("No instance found for datatable, you should set a datatable id in your action with "setDatatableId" using the id from your view ") in MySpaceGestionPatrimoinesBundle:Batiments:indexBatiments.html.twig at line 37.
, 나는이 오류이 그리고 내 코드 나뭇 가지 :
{% extends "MySpaceWelcomeBundle::layout.html.twig" %}
{% block content %}
<div class="jumbotron">
<h4><u>Rechercher un bâtiment et ses affectations spécifiques:</u></h4>
<br>
<div>
{{ datatable({
'id' : 'batiments',
'js' : {
'sAjaxSource' : path('mySpace_formulaire_recherche_batiments')
}
})
}}
</div>
</div>
{% endblock %}
정말 이해가 안되지만 누군가이 문제를 해결하도록 도와 줄 수 있습니까?
나는 이미 캐시를 지우고 자산을 설치하고 처음부터 다시 문서를 넘겨 받았다. 이해할 수 없다.
미리 감사드립니다.
Jquery Datatables를 입력하려고합니다. 도와 주셔서 감사합니다. 제가 질문이 있다면, 당신에게 묻습니다. –
@Julien, 환영합니다. 망설이지 말고, 제 프로젝트에도 마찬가지입니다. –
@Julien, 응용 프로그램에 필요한 다른 경우에 도움이되는 몇 가지 링크가 있습니다 : [symfony 용 번들] (https://datatables.net/forums/discussion/19490/datatables-with-symfony2) 및 여기 : [데이터 통합을위한 github 코드] (https://gist.github.com/Slauta/3175282) –