2013-04-07 37 views
0

我一直在使用想用我自己的数据来填充WinJS.UI.ListView

WinJS.xhr({ url: url, responseType: "json" }).then(
    function(result){}, 
    function(error){} 
); 

我就按一下按钮事件这些东西获得了数据。 我得到了正确的数据,但无法填充他们在我的ListView。 所以,现在,我怎样才能绑定我的WinJS.UI.ListView JSON数据每次点击按钮与我的新数据...?请用一些简单的例子来帮助我。因为我已经检查了很多链接。但我还是不明白其中

回答

1

它应该是这样的:

WinJS.xhr({ .. }).then(function xhrcomplete(req) 
{ 
    var data; // assuming you already have code that parsed json text to an object. 
    var items = []; 
    // fill code here to get items out of the data 
    var list = new WinJS.Binding.List(items); 
    // binding code will depend on whether listview has groupHeaderTemplate or not 
    // if not - it should be like this 
    listView.winControl.itemDataSource = list.dataSource; // listView is the id of the your list view control in html 

}).then(null, function onerror(error) 
{ 
    // handle error case 
}); 
+0

我得到这个错误:在异常即将被由JavaScript库代码的行10299抓,列5 MS-APPX: //microsoft.winjs.1.0/js/ui.js 0x800a01b6 - JavaScript运行时错误:对象不支持属性或方法'createListBinding' – 2013-04-07 08:23:36

+0

这是我的ListView控件:

2013-04-07 08:25:57

+0

没有这条线它没有给我任何种类错误或异常:listView.winControl.itemDataSource = list; – 2013-04-07 08:28:53

相关问题