我正在使用 WinJS.Binding.List() 将 Azure 移动服务数据绑定到 Listview。如何从列表视图中获取选定项的值和索引?
//Javascript
var table = client.getTable('PatientInfo');
var birthCertData = function () {
table.read().done(function (results) {
birthCert = new WinJS.Binding.List(results);
listItems.winControl.itemDataSource = birthCert.dataSource;
});
};
function selectionChangedHandler() {
//what should I type here to get the selectedCell Value and index?
}
listItems.addEventListener("selectionchanged", selectionChangedHandler, false);
这是我的html
<div id="TemplateItem" data-win-control="WinJS.Binding.Template" style="display: none">
<div style="display: -ms-grid; -ms-grid-columns: auto 1fr">
<div style="-ms-grid-column: 2; margin-left: 5px; height: 40px; text-align: center; vertical-align: middle">
<h3 data-win-bind="innerText: birthcert"></h3>
</div>
</div>
</div>
<div id="listItems" class="win-selectionstylefilled"
data-win-control="WinJS.UI.ListView"
data-win-options="{ itemTemplate: select('#TemplateItem'),
layout: {type: WinJS.UI.ListLayout},
selectionMode: 'single',
tapBehavior: 'directSelect'}">
</div>
<div style="margin: 5px 0px 0px 72px; -ms-grid-column: 2">
<input type="text" id="textInput" />
</div>
屏幕截图:http: //i.stack.imgur.com/Di0BP.png
谢谢