以下服务器端代码有效:
[OperationContract]
public IEnumerable<object> GetBooks() {
var people = new List<object>
{
new Book{ Author="Richard Preston", Title="The Hot Zone"},
new Book{ Author="Jim Norton", Title="I Hate Your Guts"}
};
return people.AsEnumerable();
}
以下是客户端代码的一部分:
<table class="Template">
<thead>
<tr>
<th>Author</th>
<th>Title</th>
</tr>
</thead>
<tbody id="bookListView">
<tr>
<td>{{Author}}</td>
<td>{{Title}}</td>
</tr>
</tbody>
</table>
function pageLoad() {
$create(Sys.UI.DataView, { serviceUri: "MyService.svc", query: "GetBooks" }, {}, {}, $get("bookListView"));
}
我希望能够将DataTable返回给客户端,并通过简单地引用每个列的名称来填充客户端模板。这可能吗?
答案 0 :(得分:1)
延迟回答,但是 - 我认为你缺少的是bookListView tbody上的class =“sys-template”。