I\'m using bootstrap table. In that I want to get Item ID
value/values of selected table rows after clicking \'Add to cart\'
button present on same
To get the selected (checked) rows, use getSelections method.
Note that if you are using pagination, then you have to use the maintainMetaData table option.
Here is an example which displays selected product's names when user clicks on Ad to cart button:
var $table = $('#myTable');
function getRowSelections() {
return $.map($table.bootstrapTable('getSelections'), function(row) {
return row;
})
}
$('#showSelectedRows').click(function() {
var selectedRows = getRowSelections();
var selectedItems = '\n';
$.each(selectedRows, function(index, value) {
selectedItems += value.name + '\n';
});
alert('The following products are selected: ' + selectedItems);
});
Item ID
Product Name
Price
1
Chair
$80
2
Sofa
$500
3
Desk
$300
4
Rug
$200