Amarendra Thakur
Amarendra Thakur

Reputation: 41

Deleting a row from JQuery Jtable Client Side only

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

Answers (3)

Daniel Serretti
Daniel Serretti

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

mOOn
mOOn

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

Amarendra Thakur
Amarendra Thakur

Reputation: 41

Here it is

deleteAction :  function (data) {
    $('#AuthorTableContainer').jtable('deleteRecord', {
        key: data.keyValue,
        clientOnly:true
    });
}},

Upvotes: 2

Related Questions