0
我有一個屏幕上的空白表:填充<Table>行與HTML
<table id="TransactionTable" class="table table-responsive table-striped">
<thead>
<tr>
<th></th>
<th>Date</th>
<th>Account</th>
<th>Third Party</th>
<th class="text-right">Amount</th>
</tr>
</thead>
<tbody></tbody>
</table>
在我的控制,我建立了一些HTML行此表,使用文本:
foreach(var i in transactions) {
tblCode += "<tr>";
tblCode += string.Format(
"<td><a href=\"@Url.Action(\"EditTransaction\", \"Transaction\" class=\"btn btn-sm btn-success\" title=\"View Transaction\">View</a></td>");
tblCode += string.Format("<td class=\"small-bold-cell\">{0}</td>", i.Date.ToString("dd.MMM.yyyy"));
tblCode += string.Format("<td class=\"small-cell\">{0}</td>", i.EntityEventTypeId == (int) Constants.EntityEventTypes.Payment ? i.DestinationEntityFull : i.SourceEntityFull);
tblCode += string.Format("<td class=\"small-cell\">{0}</td>", i.EntityEventTypeId == (int) Constants.EntityEventTypes.Payment ? i.SourceEntityFull : i.DestinationEntityFull);
tblCode += string.Format("<td class=\"small-bold-cell text-right\">{0}</td>", i.Amount.ToString("C2"));
tblCode += "</tr>";
}
然後我在JSON Result中傳遞給我的javascript,並使用Chrome瀏覽器,我可以在返回的對象中看到HTML代碼。
然後我嘗試將該HTML代碼添加到我的表中。
if (result.Success == 'true') {
$.unblockUI();
$('#TransactionTable').innerHTML = result.TableCode;
$('#transactions').modal('show');
}
else {
$.unblockUI();
alert("error");
}
但它似乎並沒有添加代碼。表格一旦顯示就沒有任何內容。
我在做什麼不正確?
謝謝你指出。解決。 – Craig 2014-10-30 18:49:46