Si prega di fare riferimento a questo html, io uso knockoutjs per generare il rapporto.
Vedi le posizioni ** (1) e ** (2)
Se elimino ** (1) e mantieni ** (2) posizione, questo funziona correttamente, ma la formattazione del mio rapporto non è quella che mi aspetto.
Se cancello ** (2) e tengo ** (1) ricevo errore dicendo "Impossibile trovare il tag di commento di chiusura in modo che corrisponda a: ko foreach: ProvinceArrayDTO" ma quello di cui ho bisogno è avere una seconda opzione e popolare gli array.
C'è un modo per realizzare questo?
In JSFiddle Buon formato DATI STATICI
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>CEB Province</th>
<th>CEB Area Office</th>
<th>Primary Substation</th>
<th>Meter</th>
<th>Time Of Use</th>
<th>Energy Initial Reading</th>
<th>Energy Final Reading</th>
<th>Total Energy in Time interval</th>
<th>Total Energy</th>
<th>Coincident Peak</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<!-- ko foreach: ProvinceArrayDTO -->
<tr>
<td data-bind="text: ProvinceName, attr: {rowspan: RowCount }"></td>
<!-- ko foreach: AreaArrayDTO -->
<td data-bind="text: AreaName, attr: {rowspan: RowCount }"></td>
<!-- ko foreach: SubStationArrayDTO -->
<td data-bind="text: SubStaionName, attr: {rowspan: RowCount }"></td>
<!-- ko foreach: MetersArrayDTO -->
<td data-bind="text: MeterName, attr: {rowspan: RowCount }"></td>
<!-- ko foreach: MetersReadingArrayDTO -->
<td class="auto-style5">Day</td>
<td class="auto-style7">LastMnValue</td>
<td class="auto-style2" data-bind="text: DayValue"></td>
<td class="auto-style2">difference</td>
<td class="auto-style4" rowspan="3">total</td>
<td rowspan="3" data-bind="text: CoincidentPeak"></td>
<td rowspan="3" data-bind="text: Remarks"></td>
</tr>**(1)
<td class="auto-style5">Peek</td>
<td class="auto-style7">9804328</td>
<td class="auto-style2">9523478</td>
<td class="auto-style2">280,850</td>
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->
</tr>**(2)
<!-- /ko -->
</tbody>
</table>
risposte:
0 per risposta № 1Grazie per le opinioni!
Ho generato il layout totale della tabella tramite javascript e il binding html di knockout utilizzato.
In Knockout
self.DetailedReport = ko.observable();
function GenerateHtmlTableFronJson(){
//JSON parse here ang generate HTML
return ("<table> ..... </table>");
}
self.DetailedReport (GenerateHtmlTableFronJson());
In HTML
<div data-bind="html: DetailedReport"></div>