how to get the id of a row in CgridView

3

Good evening I am trying to capture the id of a row from a CgridView with a pop-up window, and place it in a text box from where it is being called but it brings me value undefined in yiiframework I hope you can help me, I leave you the used code

function that calls the window where the CgridView is located

 <script >
 function buscarArticulo() {
 window.open("../articulo/catInventario", "popupId", "location=no,menubar=no,titlebar=no,resizable=no,toolbar=no, menubar=no,width=500,height=500"); 
 }
 </script>

this is the function in the pop-up window:

<script language="javascript">
function cerrar(idarticulo) {
window.opener.document.getElementById('idarticulo').value = <?php echo $model->idarticulo; //the new id ?> 
window.close();
}
</script>

this is the CgridView widget

<?php $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'catInventario-grid',
    'dataProvider'=>$model->search(),
    'filter'=>$model,
    'columns'=>array(
        'idarticulo',
        'codigo',
        'nombre',
        'descripcion',
        'imagen',
        'uso_interno',
        /*
        'idcategoria',
        'idpresentacion',
        'cod_impuesto',
        */
        array(
            'class'=>'CButtonColumn',
            'template'=>'{elegir}',
            'buttons'=>array(
                'elegir'=>array(
                    'click'=>'cerrar',
                    ),

                ),

        ),
    ),
)); ?>

this is the model, where searh is found for the full search

public function search()
{


    $criteria=new CDbCriteria;

    $criteria->compare('idarticulo',$this->idarticulo);
    $criteria->compare('codigo',$this->codigo,true);
    $criteria->compare('nombre',$this->nombre,true);
    $criteria->compare('descripcion',$this->descripcion,true);
    $criteria->compare('imagen',$this->imagen,true);
    $criteria->compare('uso_interno',$this->uso_interno,true);
    $criteria->compare('idcategoria',$this->idcategoria);
    $criteria->compare('idpresentacion',$this->idpresentacion);
    $criteria->compare('cod_impuesto',$this->cod_impuesto,true);

    return new CActiveDataProvider($this, array(
        'criteria'=>$criteria,
    ));
}

and this is the function of the controller:

public function actionCatInventario()
{
    $model=new Articulo('search');
    $model->unsetAttributes();  // clear any default values
    if(isset($_GET['Articulo']))
        $model->attributes=$_GET['Articulo'];

    $this->render('catInventario',array(
        'model'=>$model,
    ));
}

As you realize, it is for a web expense form and for this purpose I only need the idarticulo, I hope I have been clear and can help me, thank you very much for your time

    
asked by Gilberto Asuaje 11.07.2017 в 04:37
source

1 answer

0

solve, thanks to a response in the forum in English here the link for those who need it answer to this same question in the English forum

    
answered by 21.07.2017 / 10:23
source