Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Delete row from table using button - Bootstrap Table

I'm trying the row to be deleted when I click the delete icon in the table using bootstrap table.

My table:

<table id="checkDataTable">
    <thead style="color: #31708f; background-color: #d9edf7 ">
        <tr>
            <th data-field="AssetReference">Referans</th>
            <th data-field="Customer">Müsteri</th>
            <th data-field="ReceiverCompanyName">Alici Firma</th>
            <th data-field="Tools" data-formatter="StatuFormatter">Islem</th>
        </tr>
    </thead>
</table>

Javascript:

function StatuFormatter(value, row, index) {

    return "<a onclick='removeAssetEconomyCheckBillOfLadingRow()'><i class='fa fa-trash fa-2x' aria-hidden='true'></i></a>";
}

function removeAssetEconomyCheckBillOfLadingRow(id) {
    alert(id);
}

It's fine until the removeAssetEconomyCheckBillOfLadingRow function.

How can I delete inside this function?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Please try below:

$(document).on('click', 'button.deleteRow', function(event) {
  $(this).closest("tr").remove();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table id="checkDataTable" class="table">
  <thead style="color: #31708f; background-color: #d9edf7 ">
    <tr>
      <th data-field="AssetReference">Referans</th>
      <th data-field="Customer">Müşteri</th>
      <th data-field="ReceiverCompanyName">Alıcı Firma</th>
      <th data-field="Tools" data-formatter="StatuFormatter">İşlem</th>
    </tr>
  </thead>
  <tobdy>
    <tr>
      <td>Data1</td>
      <td>Data1</td>
      <td>Data1</td>
      <td><button type="button" class="deleteRow">
                    Delete
                    </button></td>
    </tr>
    <tr>
      <td>Data2</td>
      <td>Data2</td>
      <td>Data2</td>
      <td><button type="button" class="deleteRow">
                    Delete
                    </button></td>
    </tr>
    <tr>
      <td>Data3</td>
      <td>Data3</td>
      <td>Data3</td>
      <td><button type="button" class="deleteRow">
                    Delete
                    </button></td>
    </tr>
  </tobdy>
</table>

about 4 years ago · Juan Pablo Isaza Report

0

  1. First of all, you need to set id to to identify the deleting row.
<tr id="1"></tr>
  1. And get tr and remove
function removeAssetEconomyCheckBillOfLadingRow(id) {
    $('#checkDataTable').row($('#{{id}}'))).remove().draw();
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!