The exit status code '1' says something went wrong [knp snappy] - symfony

I'm working with knp snappy bundle for generate reports from my app. But doesn't work, when I call my controller for generate the pdf throws the next error:
The exit status code '1' says something went wrong:
stderr: "Loading pages (1/6)
[> ] 0%
[======> ] 10%
[=======> ] 12%
Warning: Failed to load file:///gestionresiduospel/web/bundles/usuario/css/bootstrap.css (ignore)
Warning: Failed to load file:///gestionresiduospel/web/bundles/usuario/js/bootstrap.js (ignore)
[============================================================] 100%
Counting pages (2/6)
[============================================================] Object 1 of 1
Resolving links (4/6)
[============================================================] Object 1 of 1
Loading headers and footers (5/6)
Printing pages (6/6)
[> ] Preparing
[============================================================] Page 1 of 1
Done
Exit with code 1 due to network error: ContentNotFoundError
"
stdout: ""
command: "C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" --lowquality "C:\Users\rodrigo\AppData\Local\Temp\knp_snappy5682878973ade7.09664058.html" "C:\Users\rodrigo\AppData\Local\Temp\knp_snappy56828789746968.46649162.pdf".
My controller is this:
public function historicosDetallePdfAction($id)
{
$em = $this->getDoctrine()->getManager();
//gets residuos peligrosos.
$solicitudRetiro= $em->getRepository('SolicitudRetiroBundle:SolicitudRetiro')->find($id);
//gets residuos no peligrosos
$residuosPRetirados = $em->getRepository('SolicitudRetiroBundle:RetiroResiduo')->findResiduos($id);
//retorna los residuos no peligrosos en la solicitud
$residuosNPRetirados = $em->getRepository('SolicitudRetiroBundle:RetiroResiduoNoPeligroso')->findResiduosNoPeligrosos($id);
// view generator
$html = $this->renderView('SolicitudRetiroBundle:Pdf:resumenSolicitudResiduoRetirado.html.twig', array(
'solicitudRetiro' => $solicitudRetiro,
'residuosRetirados' => $residuosPRetirados,
'residuosNoPel' => $residuosNPRetirados ));
// pdf generator
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="historico.pdf"'
)
);
}
I copied my url and run into console[CMD] with wkhtmltopdf.exe. In console my pdf is created but when I see the file only shows my login screen. So I think could be a issue about permission into my controller but I don't know how I pass this.
In other hand, if you know about another pdf generator(from html) that working into symfony this could be help me too.
I'm working under symfony2.7

This mean's that one of the resources in your HTML file can't be loaded by wkhtmltopdf, check in your HTML file if all your resources have an absolute URL like this : http://www.yourserver.com/images/myimage.jpg
If it's not the case try to set it :
{{ app.request.schemeAndHttpHost ~ 'resource relative url' }}
If you are loading assets with assetic in {% stylesheets %} or {% javascript %} or {% image %} you can also do
{{ app.request.schemeAndHttpHost ~ asset_url }}

I had two kind of problems here once:
The first one was because kpn snappy fails when trying to convert a *.js file. So I had to take *.js files in my case.
The second one was because of the path. I had to use the absolute filesystem path. By this, I mean, something like: /home/ubuntu/workspace/bootstrap/css/bootstrap.css this is used in href tag used in *html.twig file that is then transformed to pdf by snappy.
By doing this, I used some twig global variables.
twig:
form:
resources:
- 'MyBundle:Form:fields.html.twig'
- 'MyUploaderBundle:Form:fields.html.twig'
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
globals:
pathToWeb: "%kernel.root_dir%/../web"
bootstrapCss: "/home/ubuntu/workspace/MyApp/web/bootstrap/css/bootstrap.css"
mainCss: "/home/ubuntu/workspace/MyApp/web/css/main.css"
layoutCss: "/home/ubuntu/workspace/MyApp/web/css/layout.css"
In twig
<link rel="stylesheet" type="text/css" href="{{ bootstrapCss }}">
<link rel="stylesheet" type="text/css" href="{{ layoutCss }}">
<link rel="stylesheet" type="text/css" href="{{ mainCss }}">

You can use absolute_url() twig function{{ absolute_url(asset('assets/image.jpg')) }}

For me this worked, the error was from html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
{% for path in encore_entry_css_files('app') %}
<link rel="stylesheet" href="{{ absolute_url(path) }}">
{% endfor %}
</head>

This problem never gets old, I encountered this just now and I manage to solve it, here's how.
This problem mostly happens in Windows so this solution is for that.
1. Install this composer dependency wemersonjanuario/wkhtmltopdf-windows
composer require wemersonjanuario/wkhtmltopdf-windows "0.12.2.3"
2. Open your config/snappy.php and use this config.
<?php
return [
'pdf' => [
'enabled' => true,
'binary' => base_path('vendor\wemersonjanuario\wkhtmltopdf-windows\bin\64bit\wkhtmltopdf'),
'timeout' => false,
'options' => [],
'env' => [],
],
'image' => [
'enabled' => true,
'binary' => base_path('vendor\wemersonjanuario\wkhtmltoimage-windows\bin\64bit\wkhtmltoimage'),
'timeout' => false,
'options' => [
'enable-local-file-access' => true,
'keep-relative-links' => true,
],
'env' => [],
],
];
3. Make sure the blade file you loading for pdf does not contain external links, like the one below.
<head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:ital,wght#0,300;0,400;0,600;0,700;1,300;1,400;1,600;1,700&display=swap" rel="stylesheet">
</head>
4. Make sure you load assets using public_path()
<link href="{{ public_path('css/pdf.css') }}" rel="stylesheet">
<img src="{{ public_path('fancy-image.png') }}">

Related

Why opened page with AdminLTE looks broken?

I make site In laravel 9 with Inertiajs/vuejs 3 based on https://github.com/ColorlibHQ/AdminLTE 3 (dark mode).
I removed all jquery and use vuejs only. it works ok for for, but when I open site
is looks broken, like not all styles were loaded,
Please try enter to login into adminarea by url :
https://bi-currencies.my-demo-apps.tk/admin/currencies
credentials are in Login form
and pages looks like : https://prnt.sc/TCjBh0SefUMO 4
But if to refresh page with “CTRL+R” pages looks ok, in dark mode.
Any ideas why so and how that can be fixed?
More Details :
Adminare is based on https://github.com/ColorlibHQ/AdminLTE template(with "bootstrap": "^4.6.0").
Frontend is based on custom https://technext.github.io/space/v1.0.0/ template (with Bootstrap v5.0.1 )
I have the same design issue when I switch from admin area
frontend page https://bi-currencies.my-demo-apps.tk/home
I see this problem of other browsers of my Kubuntu 20 too.
Maybe problem is that that I use too different templates, but actually I use different layouts, so in
app/Http/Middleware/HandleInertiaRequests.php :
public function rootView(Request $request)
{
if ($request->segment(1) == 'user') {
return 'layouts/user';
}
if ($request->segment(1) == 'admin') {
return 'layouts/adminlte'; // TODO
}
return 'layouts/frontend'; // Current request is front-end
}
This project has no Redis or other chache tools installed. Sure I cleared all cache opening the site. Any other ideas?
Frontend template resources/views/layouts/frontend.blade.php :
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title inertia id="app_title">{{ config('app.name', 'Laravel') }}</title>
<link rel="shortcut icon" type="image/x-icon" href="/images/frontend_favicon.ico">
<link href="https://fonts.googleapis.com/css2?family=Yantramanav:wght#300;400;500;700;900&display=swap"
rel="stylesheet">
<!-- Styles -->
#routes
<!-- Scripts -->
<script src="//cdn.jsdelivr.net/npm/sweetalert2#11"></script>
<link rel="stylesheet" href="/css/theme.css">
<script src="/vendors/#popperjs/popper.min.js"></script>
<script src="/vendors/bootstrap/bootstrap.min.js"></script>
<script src="/vendors/is/is.min.js"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=window.scroll"></script>
<script src="/vendors/fontawesome/all.min.js"></script>
<script src="{{ mix('js/app.js') }}" defer></script>
</head>
<body class="bg-light sidebar-mini layout-fixed layout-footer-fixed">
#inertia
</body>
</html>
and admin template resources/views/layouts/adminlte.blade.php :
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title inertia id="app_title">{{ config('app.name', 'Laravel') }}</title>
<!-- Google Font: Source Sans Pro -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
<!-- Styles -->
<link rel="stylesheet" href="/css/OverlayScrollbars.min.css">
<link rel="stylesheet" href="/css/fontawesome_all.min.css">
<link rel="stylesheet" href="/css/adminlte.min.css">
<link rel="stylesheet" href="/css/admin_custom.css">
#routes
<!-- Scripts -->
<script src="//cdn.jsdelivr.net/npm/sweetalert2#11"></script>
<script src="/js/Chart.bundle.js"></script>
<script src="/js/OverlayScrollbars.min.js"></script>
<script src="{{ mix('js/app.js') }}" defer></script>
</head>
<body class="bg-light sidebar-mini layout-fixed layout-footer-fixed">
#inertia
</body>
</html>
1 common resources/js/app.js :
require('./bootstrap');
window.Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000,
timerProgressBar: false,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
require('#fortawesome/fontawesome-free/js/all.min.js');
// Import modules...
import { createApp, h } from 'vue';
import { createInertiaApp, Link } from '#inertiajs/inertia-vue3';
import { InertiaProgress } from '#inertiajs/progress';
import mitt from 'mitt';
window.emitter = mitt();
const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';
import Multiselect from '#vueform/multiselect'
import VueUploadComponent from 'vue-upload-component'
import Paginate from "vuejs-paginate-next";
const app = createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) => require(`./Pages/${name}.vue`),
setup({ el, app, props, plugin }) {
return createApp({ render: () => h(app, props) })
.use(plugin)
.component('inertia-link', Link)
.component('Paginate', Paginate)
.component('file-upload', VueUploadComponent)
.mixin({ methods: { route } })
.component('multiselect', Multiselect)
.mount(el);
},
});
InertiaProgress.init({ color: '#4B5563' });
also in admin/settings page I added “Clear Cache” button, clicking on it next commands are run :
\Artisan::call('config:cache');
\Artisan::call('route:cache');
\Artisan::call('cache:clear');
\Artisan::call('route:cache');
\Artisan::call('route:clear');
\Artisan::call('view:clear');
\Artisan::call('clear-compiled');
but clearing cache did not help with this problem.
Can it be that reason of this problem that I have 1 common resources/js/app.js both for admin area and frontend part?
Thanks!
Once I was faced same problem with inertia and that works for me. Usually that happened when you used multiple-layouts, as well as those layout have different style-scripts.
Reason (problem):
As you have used one layout for frontend-pages (public pages) and other one for admin-pages.
So when user visited front-pages, all style scripts of frontend-layout loaded and it's work fine and looks good.
But, when user switched to admin-layout that's layout style-scripts not loaded. So, On hard-refresh (Crtl+R) that URL the appropriate layout style-scripts got loaded.
I read many article to switch layouts on run-time every article gives same solutions as you did in HandleInertiaRequests.php.
Solution:
Then I come to a point where I need to switch layout on clicking some link I did hard-loading as shown in below snippet instead of redirection by inertia-link:
<a :href="route('home')">
Home
</a>
By this way appropriate layout style-script got loaded.
My Assumption:
Moreover, I've seen your site-source-code (Ctrl+U) as shown in screenshot. You haven't loaded style-scripts by Laravel asset() helper method.
I suggest to try once by loading scripts & style link in blade file by Laravel standard approach (using asset() method) that might be a problem.
Attach CSS sheet
<link href="{{ asset('frontend/css/bootstrap.min.css') }}" rel="stylesheet">
Attach JavaScript/jQuery scripts
<script src="{{ asset('frontend/js/jquery-3.5.1.min.js') }}"></script>
After using asset() method, your links in site-source-code (Ctrl+U)
looks something like that:
Note:
make sure you must set appropriate APP_URL in .env file.

How to use Select2 Ajax in Symfony combined with Twig

I'm trying to use Select2 Ajax in my HTML page to seach through my dataset. I have multiple errors:
Search bar is almost invisible
If does not shown any data
ProductController
/**
* #Route("/api/product/v1/select2search", name="api_product_search")
*/
public function viewAction()
{
$products = $this->productRepository->findAll();
foreach ($products as $entity) {
$response1[] = array(
'id' => $entity['id'],
);
$response2[] = array(
'name' => $entity['name'],
);
}
return new JsonResponse(([$response1,$response2]));
}
My twig file:
{% extends 'base.html.twig' %}
{% block body %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<!-- select2 -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
<link href="https://cdn.jsdelivr.net/gh/ttskch/select2-bootstrap4-theme#master/dist/select2-bootstrap4.min.css" rel="stylesheet">
<select class="js-data-example-ajax"></select>
<script>
$('.js-data-example-ajax').select2({
ajax: {
url: 'http://127.0.0.1:8000/api/product/v1/select2search',
dataType: 'json'
// Additional AJAX parameters go here; see the end of this chapter for the full code of this example
}
});
</script>
{% endblock %}
The current visual screen:
You can not see the bar as described above.
My goal to achieve is this:

How to load file JS and CSS using herbert, enqueue

I'm following the example of the official website.
$enqueue->front([
'as' => 'vueJS',
'src' => Helper::assetUrl('/js/vue.js')
]);
And I need it to load in a view, I use the example of the official page.
<!DOCTYPE html>
<html>
<head>
<title>Profesores</title>
</head>
<body>
<h1>{{ title }}</h1>
<p>{{ content }}</p>
</body>
</html>
I use a controller to load the view
public function getProfesores()
{
$profesores = Profesor::all();
return view('#MyPlugin/profesores/lista.twig', [
'title' => 'My Demo',
'content' => 'Congrats on your demo view.',
'data'=> json_response($profesores->toArray())
]);
}
Maybe it's easy but it does not work for me, can someone help me?

django template won't load css and javascript files

I am creating an application in django and everything works great, except one template. all the template load the javascript and css files with any problem, but there's one template doen't load any css or JS file.
When I am typing the view of this template I make an typo error and after I fix it the template won't load any css or JS file
UPDATE: View definition indented
view
#permission_required('prov.views.configView',login_url='/login/')
def MasterFormView(request):
form = MasterForm(request.POST or None)
if request.method == 'POST':
idp = request.POST['id_proveedor']
a = request.POST['anio']
m = request.POST['mes']
id = Proveedor.objects.get(id_proveedor=idp)
obj,created = Master.objects.get_or_create(id_proveedor=id,anio=a,mes=m)
if form.is_valid():
objdetrec,createddetrec = DetalleRecepcion.objects.get_or_create(id_proveedor=id,anio=a,mes=m)
objdetcar,createddetcar = DetalleCargaArchivo.objects.get_or_create(id_proveedor=id,anio=a,mes=m)
objdetcon,createddetcon = DetalleConci.objects.get_or_create(id_proveedor=id,anio=a,mes=m)
objenvcon,createdenvcon = EnvioConci.objects.get_or_create(id_proveedor=id,anio=a,mes=m)
objcer,createdcer = Certificado.objects.get_or_create(id_proveedor=id,anio=a,mes=m)
objentcert,createdentcert = EntCertificado.objects.get_or_create(id_proveedor=id,anio=a,mes=m)
objacepta,createdacepta = AceptCertificado.objects.get_or_create(id_proveedor=id,anio=a,mes=m)
objrepro,createdrepro = Reproceso.objects.get_or_create(id_proveedor=id,anio=a,mes=m)
return HttpResponseRedirect('/monitor/')
if not created:
obj.id_proveedor = id
obj.anio = a
obj.mes = m
#-----------------------------
objdetrec.id_proveedor = id
objdetrec.anio = a
objdetrec.mes = m
#----------------------------
objdetcar.id_proveedor = id
objdetcar.anio = a
objdetcar.mes = m
#----------------------------
objdetcon.id_proveedor = id
objdetcon.anio = a
objdetcon.mes = m
#----------------------------
objenvcon.id_proveedor = id
objenvcon.anio = a
objenvcon.mes = m
#----------------------------
objcer.id_proveedor = id
objcer.anio = a
objcer.mes = m
#----------------------------
objentcert.id_proveedor = id
objentcert.anio = a
objentcert.mes = m
#----------------------------
objacepta.id_proveedor = id
objacepta.anio = a
objacepta.mes = m
#----------------------------
objrepro.id_proveedor = id
objrepro.anio = a
objrepro.mes = m
#----------------------------
obj.save()
objdetrec.save()
objdetcar.save()
objdetcon.save()
objenvcon.save()
objcer.save()
objentcert.save()
objacepta.ave()
objrepro.save()
return HttpResponseRedirect('/monitor/')
return render_to_response('masterform.html',
{'form':form})
form:
class MasterForm(forms.ModelForm):
def __init__(self,*args,**kwargs):
super(MasterForm,self).__init__(*args,**kwargs)
self.helper = FormHelper(self)
self.helper.layout.append(Submit('save','Grabar'))
self.helper.layout = Layout(
Fieldset('',
'id_proveedor',
'anio',
'mes',
Submit('save','Grabar'),
)
)
class Meta:
model = Master
url:
url(r'^masterform/$', 'prov.views.MasterFormView',name='masterform'),
The form update all the models specified and works fine, but doesn't have style or JS functions.
I don't know why all the others template can load the css files and this form don't
Anybody have the same issue or any idea how to fix this.
P.D.: in firebug the error is "PAGE NOT FOUND"
UPDATE Add the code of the html templates
masterform.html
{% extends 'base.html' %}
{% load crispy_forms_tags %}
{% block content %}
<div class="container">
<div class="col-sm-4"
<form method='POST' action='' class='form'>
<div class="form-group">
{% csrf_token %}
{% crispy form %}
</div>
</form>
</div>
</div>
{% endblock %}
base.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>Proveedores de Contenido</title>
<!-- Bootstrap core CSS -->
<link href="{{STATIC_URL|default:"/static/"}}admin/css/bootstrap.min.css" rel="stylesheet">
<link href="{{STATIC_URL|default:"/static/"}}admin/css/custom.css" rel="stylesheet">
<link href="{{STATIC_URL|default:"/static/"}}admin/css/jquery.dataTables.css" rel="stylesheet">
<link href="{{STATIC_URL|default:"/static/"}}admin/css/customtable.css" rel="stylesheet">
<link href="{{STATIC_URL|default:"/static/"}}admin/css/bootstrap-theme.min.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="{{STATIC_URL|default:"/static/"}}admin/js/bootstrap.js"></script>
<!-- script type="text/javascript" src="/static/admin/js/jquery-1.11.1.min.js"></script -->
<script src="{{STATIC_URL|default:"/static/"}}admin/js/jquery.dataTables.js"></script>
<script src="{{STATIC_URL|default:"/static/"}}admin/js/dataTables.bootstrap.js"></script>
</head>
<body>
{% block content %}{% endblock %}
{% include 'footer.html'%}
</body>
</html>
When I create the viwe, form and template works fine and load every css and js file.
Later I make a change and accidentally type wrong some word. After I fix the typo error is the template won't load my css and js files.
But the form works fine, only don't have style.
I am thinking in rewrite all (view, form, htmltemplates and change the url) and see if there some corrupt file or configuration
It seems like your redirecting yourself to the masterform.html. This is where css and javascript are loaded.
Edit:
The files cant be found because you haven't the correct settings:
For app:
STATIC_URL = '/static/'
For prodject:STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
'/var/www/static/',
)
add these two settings to your settings file and dont forget to load them:
{% load staticfiles %}
at the top of all your html files.
Then you will not need your {{STATIC_URL | default}} anymore just use {{ STATIC_URL}}
Manage static files
Suggestion:
Make a {%block exta_head %} {% endblock %}
inside your of your main template so your extended templates can add there own files.

Getting JSON error while trying to use the AliDatatableBundle

I'm trying to use the AliDatatableBundle and I follow every step as docs say, so this is how my controller looks like:
public function indexAction(Request $request) {
$this->_datatable();
return $this->render('PICommonBundle:Default:index.html.twig');
}
private function _datatable() {
return $this->get('datatable')
->setEntity("PIProyectoBundle:Proyectos", "p")
->setFields(
array(
"Nombre" => 'p.nombre',
"Centros" => 'c.descripcion',
"Unidades" => 'u.descripcion',
"_identifier_" => 'p.id')
)
->addJoin('p.centros', 'c', \Doctrine\ORM\Query\Expr\Join::INNER_JOIN)
->addJoin('p.unidades', 'u', \Doctrine\ORM\Query\Expr\Join::INNER_JOIN);
}
public function gridAction() {
return $this->_datatable()->execute();
}
And this is my template:
{% extends '::base.html.twig' %}
{% block content %}
<link href="{{ asset('bundles/alidatatable/css/demo_table.css') }}" type="text/css" rel="stylesheet" />
<link href="{{ asset('bundles/alidatatable/css/smoothness/jquery-ui-1.8.4.custom.css') }}" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="{{ asset('bundles/alidatatable/js/jquery.datatable.inc.js') }}"></script>
<script type="text/javascript" src="{{ asset('bundles/alidatatable/js/jquery.dataTables.min.js') }}"></script>
{{
datatable({
'edit_route' : 'editar-asistencia',
'delete_route' : 'eliminar-asistencia',
'js' : {
'sAjaxSource' : path('informes')
}
})
}}
{% endblock %}
But any time I try to execute the page I get this error:
DataTables warning (table id = 'ali-dta_98f13708210194c475687be6106a3b84'):
DataTables warning: JSON data from server could not be parsed. This is caused > by a JSON formatting error.
Any advice? I'm using latest jQuery 1.10.2.
are you spanish?
(i´m too !!)
I think your problem is whit sAjaxSource.
Read this tip:
Ali en github
At the end of post comment:
"I took a look on your code and even tested it: your error is too simple , the "sAjaxSource" have to include the route for the grid action and not the index action "
In my case this solved:
In (bundle) routing.yml:
empleados_grid:
pattern: /empleados_grid
defaults: { _controller: MyBundle:Empleados:grid }
and in twig template:
{{ datatable({
'edit_route' : 'empleados_update',
'delete_route' : 'empleados_delete',
'js' : {
'sAjaxSource' : path('empleados_grid')
}
})
}}

Resources