JSFiddle - React, Tailwind, and code Playground

by jimkennelly

HTML

<script src="https://code.jquery.com/jquery-3.4.1.slim.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/bootstrap-table.min.css">

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/bootstrap-table.min.js"></script>

<div id="toolbar">
  <button id="button1" class="btn btn-secondary">click me to see method: updateCellByUniqueId</button>
</div>
<table
  id="table1"

  data-toolbar="#toolbar"
  data-height="428"
  data-unique-id="id"
  >
  <thead>
    <tr>
      <th data-field="id">ID</th>
      <th data-field="name">Item Name</th>
      <th data-field="price">Item Price</th>
    </tr>
  </thead>
</table>

CSS

.row {
  background: #f8f9fa;
  margin-top: 20px;
}

.col {
  border: solid 1px #6c757d;
  padding: 10px;
}

JavaScript

var $table = $('#table1')
  var $button1 = $('#button1')
$table.bootstrapTable({
  data: [{
    id: 1,
    name: 'Item 1',
    price: '$1'
  }, {
    id: 2,
    name: 'Item 2',
    price: '$2'
  }]
})
$button1.click(function () {
			newItemName = prompt("Enter new item name");
      var randomId = 'xxxx';
      $table.bootstrapTable('updateByUniqueId', {
        id: 1,
        row: {
          name: newValue = newItemName,
          price: '$' + randomId
        }
      })
      // toastr["success"]("Record updated to new item name",newItemName);

    })