I've view page(index.php
) in my Yii2 project, and I'm using Kartik gridView for showing the data
This the view from index.php:
On the right side of view, I've a checkbox column. And I've an Export button. I want to export the selected name (selected by checkbox) into name.txt
file.
I've finally make the export function, but I don't know how to get the selected data from view into controller.
I've try suggestions that I got from many forums, for example:
I put this javascript code in my view index.php
:
<script>
function getRows(){
var keys = $('#grid').yiiGridView('getSelectedRows');
$.post({
url: FakturOutController / exportAction,
dataType: 'json',
data: {keylist: keys},
success: function(data) {
alert('I did it! Processed checked rows.')
},
});
}
and set the export button like this:
<p>
<button type="button" onclick="displayResult()" class="btn btn-success">Export</button>
</p>
But I got nothing, the button didn't showed any action/reaction when clicked.
Any help would be appreciated. Thanks
Aucun commentaire:
Enregistrer un commentaire