send row to modal view

hello, I have a gridview where you have selected some lines that I would like to send to a modal window to be able to process them.

my view:




$script = <<< JS

$(function(){

  $('#btnAffido').click(function(){

      // recupero le righe selezionate

      pk= $('#gridPratiche').yiiGridView('getSelectedRows'); 

      if (pk != ''){

         $('.modal').modal('show')

            .find('#modelContent')

            .load($(this).attrs('value'));

      }

  });

});

JS;

$this->registerJs($script);

<?= Html::a('Create Pratiche', ['create'], ['class' => 'btn btn-success']) ?>



my controller




  /* Gestione Affido */

     public function actionAffido()

    {

        var keys = $('#grid').yiiGridView('getSelectedRows');

        $model = new AssegnazionePratiche();


        return $this->renderAjax('affido', [

            'model' => $model,

        ]);

    }



Any suggestions ? Thank you all

I think there’s a little bit of confusion in your code (or maybe I don’t understand it…):

How can this work in your controller? It’s Javascript inside PHP…


var keys = $('#grid').yiiGridView('getSelectedRows');

Then in your view you need to cycle through the selected checkboxes to create the rows in a table, or the divs or whatever you want to use in the modal (I don’t know where you get $(this).attrs from…). I think this link could help you: http://www.yiiframework.com/forum/index.php/topic/53777-gridview-get-selected-colum/

HTH, cheers!