Reputation: 41
I am trying to delete a row from JTable in client side only.But somehow i am not able to get the value of the key of the selected record.See the code below
deleteAction : function (postData) {
var row_id = $('.jtable-data-row').attr('data-record-key');
$('#AuthorTableContainer').jtable('deleteRecord', {
key: row_id,
clientOnly:true
});
}},
The problem is when the table contains the multiple record.then in that case "tr" attributes become
"jtable-data-row jtable-row-even" in that case i am not able to get the value of the data-record-key.
Is there any other way to delete a row from JTable from client side only?
Upvotes: 2
Views: 1742
Reputation: 342
In order to remove a row from a JTable
, you will need to remove the target row from the underlying TableModel
. If, for instance, your TableModel
is an instance of DefaultTableModel
, you can remove a row by doing the following:
((DefaultTableModel)myJTable.getModel()).removeRow(rowToRemove);
Upvotes: 1
Reputation: 1
If you want to delete any record from jtable and you only know key that's what with my case just pass it like below.
$('#detailVoucherTable').jtable('deleteRecord', { key: 0, clientOnly:true });
Regards mOOn [email protected]
Upvotes: 0
Reputation: 41
Here it is
deleteAction : function (data) {
$('#AuthorTableContainer').jtable('deleteRecord', {
key: data.keyValue,
clientOnly:true
});
}},
Upvotes: 2