add button selected rows grid.

Good morning I want to place a button to select some rows of a grid, I made this code, but not how to do good javascript code, if anyone can help me:

My Code:




Html::button('<i class="glyphicon glyphicon-download-alt"></i><span>&nbsp;&nbsp; Descargar Registros Seleccionados</span>',

                ['type'=>'button', 'class'=>'btn btn-success',

                'onclick'=>'var keys = $("#kv-grid-table").yiiGridView("getSelectedRows").length; alert(keys > 0 ? "Downloaded " + keys + "selected register to your account." : "No rows selected for download.");'

            ]),



Thks,

Wilmer.

Solved

Would you mind telling us how you solved this?

Easy:




    <?php echo GridView::widget([

        'id' => 'kv-grid',

        'dataProvider'=> $dataProvider,

        'filterModel' => $searchModel,

    ]) ?>


    Html::button('<i class="glyphicon glyphicon-download-alt"></i><span>&nbsp;&nbsp; Filter Rows Select</span>',

                ['type'=>'button', 'class'=>'btn btn-success',

                'onclick'=>'var keys = $("#kv-grid").yiiGridView("getSelectedRows").length; alert(keys > 0 ? "Ha Seleccionado: " + keys + " Registros para Filtrar." : "No hay registros Seleccionados para Filtrar.");'

    ])



Hello, I need to understand how I can transfer the selected ids to a modal window to be able to modify them in a massive way you could give me some suggestions