Sum of selected rows
Sum of selected rows
hsenmsh
Posts: 1Questions: 1Answers: 0
Hi ,
i need to get the sum of selected rows : on key-focus and row select trigger
thats my code :
var table = $('#mytable').DataTable({
ajax:{
url: "jsonTable.php", // Change this URL to where your json data comes from
type: "POST", // This is the default value, could also be POST, or anything you want.
data: function(d) {
d.payment_type = $("#payment_type").val()
}
},
select: true,
keys: true,
processing : true ,
});
table
.on('key-focus', function (e, datatable, cell) {
datatable.row( cell.index().row ).select();
// here i need to get the sum of selected row when i use the keyboard shortcut
});
This discussion has been closed.
Answers
You can use the sum() plugin along with the
selector-modifier
of{selected: true}
with therows().data()
API. Here is an example:http://live.datatables.net/tadohigi/1/edit
Note the use of
pluck()
to get the 4th column (Age) of data.Kevin