Please let me know, where I'm going wrong.
I have a button and on its click , it calls 'GetSelectedRecords()' , where im trying to fetch the multiple selected row values.
my script code below
function GetSelectedRecords() {
var table = $('#gridview').DataTable();
$(this).toggleClass('selected');
var AllData = [];
$('.selected').each(function () {
var pos = table.row('.selected').index();
var row = table.row(pos).data();
AllData.push(row);
});
}
What I have tried:
I have also tried using like below
<pre>$('.selected').each(function (i,v) {
var pos = table.row('i').index();
and selected two rows in the grid, it returns me the first row value of the grid twice, instead of selected rows values.
also tried the below code
$('.selected').each(function (ind) {
var row = table.row(ind).data();
AllData.push(row);
});
and selected 2 rows in the grid , in alert it gives me some random 2 different row number , which are also present in the grid, but not selected value rows.