将数据从Firestore显示到引导HTML表中

问题描述 投票:3回答:1

enter image description here我想将我的CoverTransaction集合中的数据显示到引导表中。虽然可以正确检索数据(显示在控制台中),但是当我从Firestore加载数据时,诸如显示条目,分页之类的引导程序功能似乎不起作用。是使用Bootstrap表造成的吗?

const coverTransTableBody = document.getElementById('coverTrans_fields');
const CoverTransactionRef = db.collection('HdCoverTransaction');
[![enter image description here][1]][1]
CoverTransactionRef.get().then(snapshot => {
  var content = '';

  snapshot.docs.forEach(doc => {

    var coverSummary = doc.data();
    console.log(coverSummary);
    let html = `<tr>
            <td>${doc.id}</td>
            <td>${coverSummary.ReceiptNo}</td>
            <td>${coverSummary.TransType}</td>
            <td>${coverSummary.OpenStock}</td>
            <td>${coverSummary.TotalQty}</td>
            <td>${coverSummary.ClosingStock}</td>
            </tr>`;
    content += html;
    coverTransTableBody.innerHTML = content;

  }, error => {
    console.log(error.message);
  });
});
<!-- Jquery DataTable Plugin Js -->
<script src="plugins/jquery-datatable/jquery.dataTables.js"></script>
<script src="plugins/jquery-datatable/skin/bootstrap/js/dataTables.bootstrap.js"></script>
<script src="js/pages/tables/jquery-datatable.js"></script>

<div class="table-responsive">
  <table id="tabel_CoverTrans_details" class="table table-bordered table-striped table-hover js-basic-example dataTable">
    <thead>
      <tr>
        <th>Date & Time</th>
        <th>Receipt No</th>
        <th>Rec/Iss</th>
        <th>Open Stock</th>
        <th>Total Qty</th>
        <th>Closing Stock</th>
      </tr>
    </thead>
    <tbody id="coverTrans_fields">
    </tbody>
  </table>
</div>
javascript html google-cloud-firestore bootstrap-table data-retrieval
1个回答
-1
投票

您可能需要在HTML文件中添加Bootstrap依赖项。

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"> </script>

让我知道它是否有效。

© www.soinside.com 2019 - 2024. All rights reserved.