RowAction in a Vector source APYDataGridBundle Symfony 2
NickName:ojotas Ask DateTime:2015-06-11T04:13:18

RowAction in a Vector source APYDataGridBundle Symfony 2

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

More about “RowAction in a Vector source APYDataGridBundle Symfony 2” related questions

RowAction in a Vector source APYDataGridBundle Symfony 2

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

Show Detail

Symfony2 APYDataGridbundle ManyToMany

I’m working with Symfony2 and APYDataGridBundle. I have a many to many relationship, between Film and Genre objects: /** * Film * * @ORM\Table(name="Film") * @ORM\Entity(repositoryClass="Filmoteca\

Show Detail

add new column in APYDataGridBundle nor work

I try add new column to APYDataGridBundle here is code : $source->manipulateRow( function ($row) { /** * @var $row Row ...

Show Detail

Symfony2 - APYDataGridBundle - Translate title in Entity annotations

can someone give me a hint about how to set the translated title in the annotations used by the APYDataGridBundle. I have already taken a look at the documentation but the 3 lines of explanation do...

Show Detail

How to show relational columns in grid using APYDataGridBundle?

I use APYDataGridBundle for generating a data table. I have Person entity with a relation (1 gym can have more people): /** * @ORM\ManyToOne(targetEntity="App\Entity\Gym", inversedBy="

Show Detail

Manipulating the query builder - Symfony - APYGRIDBundle

I am trying to query database and display results to the APYDataGridBundle,in Symfony. To accomplish this I am using your sample example https://github.com/APY/APYDataGridBundle/blob/master/Resourc...

Show Detail

Symfony/Twig can't extend a template when displaying a grid with APYDataGridBundle

I have a base.html.twig template that I have successfully extended in an index.html.twig file, which I take to mean that the base.html.twig file is well formed and being called correctly (this is my

Show Detail

APYDataGridBundle: For aliased column data not displayed

I am using the APYDataGridBundle for Symfony2. My final objective is to have one line per user in the grid (ok for now) and to have a favoris_id column with the id or null (then with JS I can mana...

Show Detail

RowAction styles lost while sorting Telerik extension grid

I am using Grid control from Telerik Extensions for ASP.NET MVC. I have loaded the grid in the partial view using Ajax binding. When I sort the grid columns, the styles specified in RowAction are l...

Show Detail

Changing row color in Kendo MVC grid, using RowAction

I'm hoping to use RowAction with a lambda to set the background color of a few rows of data in a Grid. <%: Html.Kendo().Grid<HomeController.SuccessfulBuildsByDevice>() ...

Show Detail