1

次のサーバー側コードが機能します。

[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 を返し、各列の名前を参照するだけでクライアント テンプレートを設定できるようにしたいと考えています。それは可能ですか?

4

1 に答える 1