RowAction in a Vector source APYDataGridBundle Symfony 2

309 Views Asked by At

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). 
1

There are 1 best solutions below

0
On BEST ANSWER

I ended up using an Entity source instead of a Vector, and because the data was from a stored procedure/native query, it was imposible for doctrine to find me the current row with the id, so my client ended up creating a new stored procedure that uses the row id as a parameters and fetch me up the row data.