0
我正在嘗試使用KO綁定的表格。按照本教程中的示例http://knockoutjs.com/examples/grid.html,我已將網格變爲此變量。在基因敲除JS網格中創建hrefs
var PagedGridModel = function(items) {
this.items = ko.observableArray(items);
this.gridViewModel = new ko.simpleGrid.viewModel({
data: this.items,
columns: [
{ headerText: "Date Created", rowText: function (response) {
var d = new Date(response.postingDate);
return d.toLocaleDateString();
} },
{ headerText: "Subject", rowText: "subject" },
{ headerText: "Status", rowText: "status" },
{ headerText: "Date Updated", rowText: function (response) {
var d = new Date(response.updationDate);
return d.toLocaleDateString();
} },
{ headerText: "", rowText: function (response) { } }
],
pageSize: 10
});
};
我需要在最後一行文本中寫一個函數來爲我的頁面創建一個超鏈接。這是我試圖用Knockout替換的JSP。
<c:forEach items="${responses}" var="response">
<tr>
<td>${response.postingDate}</td>
<td>${response.subject}</td>
<td>${response.status}</td>
<td>${response.updationDate}</td>
<c:url value="/contact/viewDetails" var="viewDetailsURL">
<c:param name="ticketId" value="${response.ticketID}"/>
</c:url>
<td><a href="${viewDetailsURL}">View Details</a></td>
</tr>
</c:forEach>
如何在最後一個rowText函數中爲「View Details」創建一個href?
見http://knockoutjs.com/documentation/attr-binding.html –