Estoy tratando de combinar datos en fila según la fecha, pero obtuve esto
necesito el resultado asi
Las columnas se están generando dinámicamente. Esta es la lógica que probé. Por favor guíame. Gracias.
var vHtml = '<table id="example_Day" class="table table-hover" cellspacing="0" width="100%">'; vHtml += '<thead>'; vHtml += '<tr id="rowDay">'; vHtml += '<th>Date</th>'; for (var i = 0; i < count; i++) { ProductArray.push(Returndata[i]["ShortCode"]); DateArray.push(Returndata[i]["DemandDate"]); MedIDArray.push(Returndata[i]["MedicineID"]); } ProductArray = ProductArray.filter(onlyUnique); for (var i = 0; i < ProductArray.length; i++) { vHtml += '<th>' + ProductArray[i] + '</th>'; } vHtml += '<th>Paid / Free</th>'; vHtml += '</tr>'; vHtml += '</thead>'; vHtml += '<tbody>'; DateArray = DateArray.filter(onlyUnique); MedIDArray = MedIDArray.filter(onlyUnique); for (var j = 0; j < count; j++) { vHtml += '<tr>'; vHtml += '<td>' + Returndata[j]["DemandDate"] + '</td>'; for (var i = 0; i < MedIDArray.length; i++) { if (MedIDArray[i] == Returndata[j]["MedicineID"]){ vHtml += '<td>' + Returndata[j]["Amount"] + '</td>'; } else { vHtml += '<td> - </td>'; } } vHtml += '<td>' + Returndata[j]["FreeOrPaid"] + '</td>'; vHtml += '</tr>'; } vHtml += '</tbody>'; vHtml += '</table>'; $('#table_day').html(vHtml);1 :
2 :