mercredi 3 avril 2019

Can't append firebase list data to html table because of push id

I tried appending firebase data to an html table but it doesn't seem to work. The push ids might be a causing factor. Anyone with knowledge on how to fix this? Below is my code.

HTML

<div class="table100-head">
<table>
<thead>
<tr class="row100 head">
<th class="cell100 column1">Staff Name</th>
<th class="cell100 column2">Department</th>
<th class="cell100 column3">Issue</th>
<th class="cell100 column4">Issued To</th>
<th class="cell100 column5">Time Reported</th>
<th class="cell100 column6">Issue Status</th>
<th class="cell100 column7">Time Solved</th>
</tr>
</thead>
</table>
</div>
<div class="table100-body js-pscroll">
<table id="table_body">
<tbody>

</tbody>
</table>
</div>

JS

(function() {

// Initialize Firebase
var config = {
apiKey: "AIzaSyDPpRANYCrbxoiQ7AG_orWOAtSlplK8g7c",
authDomain: "hotel-report-ticketing-system.firebaseapp.com",
databaseURL: "https://hotel-report-ticketing-system.firebaseio.com",
projectId: "hotel-report-ticketing-system",
storageBucket: "hotel-report-ticketing-system.appspot.com",
messagingSenderId: "731845033376"
};
firebase.initializeApp(config);

var rootRef = firebase.database().ref().child("Hotel 
Complaints").child("Hotel Complaintsid");

rootRef.on("child_added", snap => {

var staff_n = snap.child("staff_name").val();
    var staff_d = snap.child("staff_department").val();
    var issue = snap.child("issue_description").val();
    var issue_t = snap.child("issue_to").val();
    var issue_tym = snap.child("issue_time").val();
    var issue_s = snap.child("issue_status").val();
    var issue_t_s = snap.child("time_solved").val();

    $("#table_body").append("<tr><td>" + staff_n + "</td><td>" + staff_d + "</td><td>" + issue + "</td><td>" + issue_t + "</td><td>" + issue_tym + "</td><td>" +
    issue_s + "</td><td>" + issue_t_s + "</td></tr>");
});

});

The firebase database snapshot

What could be my problem?




Aucun commentaire:

Enregistrer un commentaire