Im stuck with this issue for a few days, i currently have grid filled with results from a Stored Procedure, i run a nativequery with the SP, get the results in an Array and use the Vector class from ApyDataGrid to display the results.
All of the above is working fine, the issue is that if i want to add a rowAction, and want to pass the data from that row to a controller, the only data i can get is the row id, nothing else, with is kind of weid because in other cases where i have a grid with an Entity source i get all the data.
From i been looking its looks like i should be getting everything from the row. But every example that im seeing doesnt show the controller that handle the RowAction, so probably my problem is that i dont know how to handle a RowAction from a Vector.
Edit:
$rsm= new ResultSetMapping();
$rsm->addEntityResult('Unisem\AppBundle\Entity\StoredProcedure', 'sp');
$rsm->addFieldResult('sp', 'Fecha', 'fecha');
$rsm->addFieldResult('sp', 'IntCod', 'iinternacionCodigo');
$rsm->addFieldResult('sp', 'Apenom', 'apenom');
$rsm->addFieldResult('sp', 'Domicilio', 'domicilio');
$rsm->addFieldResult('sp', 'ServicioDesc', 'descripcion');
$rsm->addFieldResult('sp', 'OsoCod', 'oSocial');
$rsm->addFieldResult('sp', 'Cliente', 'cliente');
$rsm->addFieldResult('sp', 'ServRealizado', 'servRealizado');
$rsm->addFieldResult('sp', 'FechaRealizado', 'fechaRealizado');
$rsm->addFieldResult('sp', 'MedCodRealizado', 'medCodRealizado');
$rsm->addFieldResult('sp', 'MedDescRealizado', 'medDescRealizado');
$rsm->addFieldResult('sp', 'Cancel_Desc', 'cancel_Desc');
$rsm->addFieldResult('sp', 'PractCod', 'practCod');
$rsm->addFieldResult('sp', 'Tipo', 'tipo');
$rsm->addFieldResult('sp', 'CodIncid', 'codIncid');
$rsm->addFieldResult('sp', 'TienePrimerHC', 'tienePrimerHC');
$rsm->addFieldResult('sp', 'Telefono', 'telefono');
$rsm->addFieldResult('sp', 'Edad', 'edad');
$rsm->addFieldResult('sp', 'FechaNac', 'fechaNac');
$rsm->addFieldResult('sp', 'DNI', 'DNI');
$em = $this->getDoctrine()->getManager('extra');
$query = $em->createNativeQuery($storedProcedureSQL, $rsm);
$query->setParameters(
array(
'Internacion' => $param1,
'FDesde' => $param2,
'FHasta' => $param3,
'Resultado' => $param4,
'Prestador' => $param5,
'Practica' => $param6,
'Cliente' => $param7,
'UsuarioWeb' => $param8
));
$results=$query->getArrayResult();
$object = new Vector($results); //Vector is the class from APYDATAGRID
$object->setId('codIncid');
$grid = $this->get('grid');
$grid->setSource($object);
$grid->addRowAction(new RowAction('Cerrar', 'unisem_frontend_servicio_close'));
And now the code of the controller that handle the rowAction:
/**
* @Route("/servicio/{codIncid}", name="unisem_frontend_servicio_close")
* @Method("GET")
* @Template("UnisemAppBundle:Frontend:close.html.twig")
*/
public function closeAction(Array $vector) //i tried using entity here, it doesnt work
{
ladybug_dump($vector);
if ($entity->TienePrimerHC())
{
$serv= new RincHcIdmedico();
$form = $this->createForm(new RincHcIdmedicoType(), $serv);
}
else
{
$serv= new RincHcCompleta();
$form = $this->createForm(new RincHccompletaType(), $serv);
}
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$form->bindRequest($request);
if ($form->isValid()) {
//query create
return $this->redirect($this->generateUrl('unisem_frontend_servicio_success'));
}
}
return $this->render('UnisemAppBundle:Frontend:close.html.twig', array(
'form' => $form->createView()
));
}
The error i get is:
500 Internal Server Error - RuntimeException Controller "Unisem\AppBundle\Controller\Frontend\ServicioController::closeAction()" requires that you provide a value for the "$object" argument (because there is no default value or because there is a non optional argument after this one).
Copyright Notice:Content Author:「ojotas」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30766408/rowaction-in-a-vector-source-apydatagridbundle-symfony-2