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



      // recupero le righe selezionate

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

      if (pk != ''){









<?= 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:

HTH, cheers!