2

这是html:

<div class="itemtemplate" data-win-control="WinJS.Binding.Template">
    <h4 class="title" data-win-bind="textContent: title"></h4>
    <div class="list" data-win-control="WinJS.UI.ListView" data-win-options="{ selectionMode: 'none' }"></div>
</div>


<div class="groupeditemslist" data-win-control="WinJS.UI.ListView" data-win-options="{ selectionMode: 'none' }"></div>

我如何添加data-win-options完整的 html(没有像“ Metro: Dynamically Switching Templates with a WinJS ListView ”这样的嵌套WinJS.UI.ListView绑定数据的 javascript templateSelector?

对于主数据中的每个项目,我添加一个WinJS.Binding.List.

4

1 回答 1

0

假设您的数据格式为:

var firstLevelDataSource = new WinJS.Binding.List(
    [{title: "t1", secondLevelBinding: new WinJS.Binding.List([1])},
     {title: "t2", secondLevelBinding: new WinJS.Binding.List([2])}]);

// then you expose firstLevelDataSource as Data.firstLevelDataSource

那么,这样不行吗?

<div class="itemtemplate" data-win-control="WinJS.Binding.Template">
    <h4 class="title" data-win-bind="textContent: title"></h4>
    <div class="list" data-win-control="WinJS.UI.ListView" data-win-options="{ selectionMode: 'none', itemDataSource: secondLevelBinding.dataSource }"></div>
</div>

<div class="groupeditemslist" data-win-control="WinJS.UI.ListView" data-win-options="{ selectionMode: 'none', itemDataSource: Data.firstLevelDataSource.dataSource }"></div>
于 2012-07-07T05:01:14.713 回答