我对Symfony的后台实现有一点问题,我想在不同的表中打印一些信息,我想用Datatables系统过滤它们。我完全编码,但是当我查看信息将被打印时,它会打印任何东西并给我一个500错误,thead和tfoot打印但是tbody doens&#tt。
以下是代码:
路由:
backoffice_view:
path: /backoffice/table
defaults: { _controller: ApiBundle:Api:view }
backoffice_table_info:
path: /backoffice/table/info
defaults: { _controller: ApiBundle:Api:table }
requirements:
_method: GET
控制器:
public function tableAction() {
$datatable = $this->get('lankit_datatables')->getDatatable('ApiBundle:Entity');
return $datatable->getSearchResults();
}
public function viewAction() {
return $this->render('ApiBundle:Api:table.html.twig', array(
));
}
表格的Javascript(我得到了在每列中过滤的代码):
$('#table tfoot th').each( function () {
var title = $(this).text();
$(this).html( '<input type="text" placeholder="Busca en '+title+'" />' );
} );
var tablas = $('#table').DataTable( {
"language": {
"aria": {
"sortAscending": ": activate to sort column ascending",
"sortDescending": ": activate to sort column descending"
},
"emptyTable": "No data available in table",
"info": "Showing _START_ to _END_ of _TOTAL_ records",
"infoEmpty": "No records found",
"infoFiltered": "(filtered1 from _MAX_ total records)",
"lengthMenu": "Show _MENU_",
"search": "Search:",
"zeroRecords": "No matching records found",
"paginate": {
"previous":"Prev",
"next": "Next",
"last": "Last",
"first": "First"
}
},
"sPaginationType": "full_numbers",
"processing": true,
"serverSide": true,
"sAjaxSource": "../table/info",
"aoColumns": [
{ "mData": "data1"},
{ "mData": "data2"},
{ "mData": "data3"},
{ "mData": "data4"},
{ "mData": "data5"},
{ "mData": "data6"}
],
"lengthMenu": [
[5, 15, 20, -1],
[5, 15, 20, "All"] // change per page values here
],
// set the initial value
"pageLength": 15,
"pagingType": "bootstrap_full_number",
"order": [
[2, "asc"]
] // set first column as a default sort by asc
});
// Apply the search
tablas.columns().every( function () {
var that = this;
$( 'input', this.footer() ).on( 'keyup change', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw();
}
} );
} );
嫩枝:
<table class="table table-striped table-bordered table-hover table-checkable order-column table-header-fixed" id="table">
<thead>
<tr>
<th>Data1</th>
<th>Data2</th>
<th>Data3</th>
<th>Data4</th>
<th>Data5</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Data1</th>
<th>Data2</th>
<th>Data3</th>
<th>Data4</th>
<th>Data5</th>
</tr>
</tfoot>
<tbody>
<tr>
</tr>
</tbody>
</table>
我不知道我是否需要为该实体提供特殊存储库或使用javascript代码的问题。
提前感谢所有答案:) 卡尔
编辑: Apache错误日志:
[Thu Jul 28 13:29:38.560587 2016] [:error] [pid 8624:tid 1880] [client ::1:60679] PHP Fatal error: Class 'Symfony\\Component\\HttpKernel\\EventListener\\SaveSessionListener' not found in C:\\xampp\\htdocs\\api\\app\\cache\\prod\\classes.php on line 1837, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.561087 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP Fatal error: Class 'Symfony\\Component\\HttpKernel\\EventListener\\SaveSessionListener' not found in C:\\xampp\\htdocs\\api\\app\\cache\\prod\\classes.php on line 1837, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.561087 2016] [:error] [pid 8624:tid 1880] [client ::1:60679] PHP Stack trace:, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.561087 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP Stack trace:, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.561087 2016] [:error] [pid 8624:tid 1880] [client ::1:60679] PHP 1. {main}() C:\\xampp\\htdocs\\api\\web\\app.php:0, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.561087 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 1. {main}() C:\\xampp\\htdocs\\api\\web\\app.php:0, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.561587 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 2. Symfony\\Component\\HttpKernel\\Kernel->handle() C:\\xampp\\htdocs\\api\\web\\app.php:27, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.561587 2016] [:error] [pid 8624:tid 1880] [client ::1:60679] PHP 2. Symfony\\Component\\HttpKernel\\Kernel->handle() C:\\xampp\\htdocs\\api\\web\\app.php:27, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.561587 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 3. Symfony\\Component\\HttpKernel\\Kernel->getHttpKernel() C:\\xampp\\htdocs\\api\\app\\bootstrap.php.cache:2336, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.561587 2016] [:error] [pid 8624:tid 1880] [client ::1:60679] PHP 3. Symfony\\Component\\HttpKernel\\Kernel->getHttpKernel() C:\\xampp\\htdocs\\api\\app\\bootstrap.php.cache:2336, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.561587 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 4. Symfony\\Component\\DependencyInjection\\Container->get() C:\\xampp\\htdocs\\api\\app\\bootstrap.php.cache:2340, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.561587 2016] [:error] [pid 8624:tid 1880] [client ::1:60679] PHP 4. Symfony\\Component\\DependencyInjection\\Container->get() C:\\xampp\\htdocs\\api\\app\\bootstrap.php.cache:2340, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.561587 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 5. appProdProjectContainer->getHttpKernelService() C:\\xampp\\htdocs\\api\\app\\bootstrap.php.cache:2062, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.561587 2016] [:error] [pid 8624:tid 1880] [client ::1:60679] PHP 5. appProdProjectContainer->getHttpKernelService() C:\\xampp\\htdocs\\api\\app\\bootstrap.php.cache:2062, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.562087 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 6. Symfony\\Component\\DependencyInjection\\Container->get() C:\\xampp\\htdocs\\api\\app\\cache\\prod\\appProdProjectContainer.php:657, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.562087 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 7. appProdProjectContainer->getEventDispatcherService() C:\\xampp\\htdocs\\api\\app\\bootstrap.php.cache:2062, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.562087 2016] [:error] [pid 8624:tid 1880] [client ::1:60679] PHP 6. Symfony\\Component\\DependencyInjection\\Container->get() C:\\xampp\\htdocs\\api\\app\\cache\\prod\\appProdProjectContainer.php:657, referer: http://localhost/api/web/app_dev.php/backoffice/table
[Thu Jul 28 13:29:38.562087 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 8. Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher->addSubscriberService() C:\\xampp\\htdocs\\api\\app\\cache\\prod\\appProdProjectContainer.php:425, referer: http://localhost/api/web/app_dev.php/backoffice/historial
[Thu Jul 28 13:29:38.562087 2016] [:error] [pid 8624:tid 1880] [client ::1:60679] PHP 7. appProdProjectContainer->getEventDispatcherService() C:\\xampp\\htdocs\\api\\app\\bootstrap.php.cache:2062, referer: http://localhost/api/web/app_dev.php/backoffice/historial
[Thu Jul 28 13:29:38.562087 2016] [:error] [pid 8624:tid 1880] [client ::1:60679] PHP 8. Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher->addSubscriberService() C:\\xampp\\htdocs\\api\\app\\cache\\prod\\appProdProjectContainer.php:425, referer: http://localhost/api/web/app_dev.php/backoffice/historial
[Thu Jul 28 13:29:39.022904 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP Fatal error: Class 'Symfony\\Component\\HttpKernel\\EventListener\\SaveSessionListener' not found in C:\\xampp\\htdocs\\api\\app\\cache\\prod\\classes.php on line 1837, referer: http://localhost/api/web/metronic/css/plugins-md.min.css
[Thu Jul 28 13:29:39.022904 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP Stack trace:, referer: http://localhost/api/web/metronic/css/plugins-md.min.css
[Thu Jul 28 13:29:39.023406 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 1. {main}() C:\\xampp\\htdocs\\api\\web\\app.php:0, referer: http://localhost/api/web/metronic/css/plugins-md.min.css
[Thu Jul 28 13:29:39.023406 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 2. Symfony\\Component\\HttpKernel\\Kernel->handle() C:\\xampp\\htdocs\\api\\web\\app.php:27, referer: http://localhost/api/web/metronic/css/plugins-md.min.css
[Thu Jul 28 13:29:39.023406 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 3. Symfony\\Component\\HttpKernel\\Kernel->getHttpKernel() C:\\xampp\\htdocs\\api\\app\\bootstrap.php.cache:2336, referer: http://localhost/api/web/metronic/css/plugins-md.min.css
[Thu Jul 28 13:29:39.023906 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 4. Symfony\\Component\\DependencyInjection\\Container->get() C:\\xampp\\htdocs\\api\\app\\bootstrap.php.cache:2340, referer: http://localhost/api/web/metronic/css/plugins-md.min.css
[Thu Jul 28 13:29:39.023906 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 5. appProdProjectContainer->getHttpKernelService() C:\\xampp\\htdocs\\api\\app\\bootstrap.php.cache:2062, referer: http://localhost/api/web/metronic/css/plugins-md.min.css
[Thu Jul 28 13:29:39.023906 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 6. Symfony\\Component\\DependencyInjection\\Container->get() C:\\xampp\\htdocs\\api\\app\\cache\\prod\\appProdProjectContainer.php:657, referer: http://localhost/api/web/metronic/css/plugins-md.min.css
[Thu Jul 28 13:29:39.024407 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 7. appProdProjectContainer->getEventDispatcherService() C:\\xampp\\htdocs\\api\\app\\bootstrap.php.cache:2062, referer: http://localhost/api/web/metronic/css/plugins-md.min.css
[Thu Jul 28 13:29:39.024407 2016] [:error] [pid 8624:tid 1864] [client ::1:60685] PHP 8. Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher->addSubscriberService() C:\\xampp\\htdocs\\api\\app\\cache\\prod\\appProdProjectContainer.php:425, referer: http://localhost/api/web/metronic/css/plugins-md.min.css
问题是:当我在控制器中传递实体时,它不会回应我任何事情,我认为它来自串行器的问题。
答案 0 :(得分:0)
我发现了一个可行的解决方案,它来自第359行的数据库中的Database.php
//$fieldName = Container::camelize($fieldName);
它现在有效,它打印并过滤表格内的所有内容。