Having an issues in html table to print with unexpected comma up of the table

Viewed 13

By Doing This Method function arrow insdie for in, i am getting unexpected "," for every row. basically i'm printing fetch table data using this method to convert pdf. so when i convert it to PDFi am getting somethings like this:

,,,,
|__N0____|__Name__|___Add__|
|________|
|__01____|___Ash__|___MY___|
|__02____|__John__|___UK___|
|__03____|__Polar_|___HK___|
|  04    |  David |   US   |

why i am getting this "," (comma)up of my table, basically this comma is indicate to how many data i retrieve for API but i don't want that comma in my table...i want only the data as you can see there are four rows of data so is have 4 comma in here.

any body can help me to fixed this issues.

thank you for trying. i'd appreciate if anybody could fix this.

my code is somthings likes:

const htD= data?.data?.items.map((data)=>{

 const id =[],
     name =[],
     add =[]

id.push(data.fd.id)
name.push(data.fd.name)
add.push(data.fd.add)

let dT=[];

for (let a in id){
for (let b in name){
for (let c in add){

   const  newLT =id[a],
          newaRItem  =name[b],
          newaMItem  =add[c]


       dT += `<tr>
              <td>${newaLmItem}</td>
              <td>${newaRItem}</td>
              <td>${newaMItem}</td>

              </tr>`

}
}
}

return dT;
})


const html= `
<html>
<style>
.demo {
        border:1px solid #C0C0C0;
        border-collapse:collapse;
        padding:5px;
    page-break-inside:auto;

    margin-buttom:300px;

    table-layout:fixed;

  .demo tr{
    page-break-inside:avoid; 
    page-break-after:auto;
  }
    .demo th {
        border:2px solid #C0C0C0;
        padding:5px;
        background:#F0F0F0;
    }
    .demo td {
        border:2px solid #C0C0C0;
        padding:5px;
    text-align: center;
    }

</style>

<table class="demo">
<h2>Comdelta Technologies Sdn. Bhd</h2>
    <thead>
  <tr>
  <th>Id</th>
  <th>Name</th>
  <th>Add</th>

  </tr>
  </thead>
  <tbody>
  <tr>
  <td>${htD}</td>

  </tr>
    </tbody>
</table>

</html>`;
0 Answers
Related