Kendo UI Mobile:拉动刷新 - 列表未显示

时间:2013-01-31 14:28:09

标签: kendo-ui

动态数据未显示在列表中。以jsonp格式动态获取数据。在Chrome开发者工具中检查后,我能够看到响应。请在下面找到代码。有人可以帮我吗?

<!DOCTYPE html>
<html>
<head>
<title>Pull to refresh</title>
<script src="../../lib/jquery.min.js"></script>
<script src="../../lib/kendo.mobile.min.js"></script>
<link href="../../lib/styles/kendo.mobile.all.min.css" rel="stylesheet" />
<link href="../../lib/styles/kendo.common.min.css" rel="stylesheet" />

<div data-role="view" data-init="mobileListViewPullToRefresh" data-title="Pull to refresh">
    <header data-role="header">
        <div data-role="navbar">
            <span data-role="view-title"></span>
            <a data-align="right" data-role="button" class="nav-button" href="#index">Index</a>
        </div>
    </header>

    <ul id="pull-to-refresh-listview"></ul>
</div>

<script id="pull-to-refresh-template" type="text/x-kendo-template">
    #= Title #
</script>

<script>
function mobileListViewPullToRefresh() {
        var dataSource = new kendo.data.DataSource({
            serverPaging: true,
            pageSize: 1,
            transport: {
                read: {
                    url: "http://localhost/MvcMovieApp/Mobile/RestResponse", // the remove service url
                    dataType: "jsonp" // JSONP (JSON with padding) is required for cross-domain AJAX
                },
                parameterMap: function(options) {
                    alert(kendo.stringify(options));
                    return {
                        q: "javascript",
                        page: options.page,
                        rpp: options.pageSize
                        since_id: options.since_id //additional parameters sent to the remote service
                    };
                }
            },
            schema: { 
                data: "movies" // the data which the data source will be bound to is in the "results" field
            }
        });

    alert("Before kendoMobileListView");

    $("#pull-to-refresh-listview").kendoMobileListView({
        dataSource: dataSource ,
        pullToRefresh: function(){ alert("dataSource"); return true },
        appendOnRefresh: true,
        template: $("#pull-to-refresh-template").text(),
        endlessScroll: true,
        pullParameters: function(item) {
            return {
                since_id: item.id_str,
                page: 1
            };
        }
    });
}
</script>
<script>
 window.kendoMobileApplication = new kendo.mobile.Application(document.body);
</script>
</body>
</html>

我收到的JSONP是: ({“电影”:[{“ID”:1,“标题”:“电影1”,“发布日期”:“/日期(1355250600000)/”,“类型”:“喜剧”,“价格”:10} ,{“ID”:2,“标题”:“电影2”,“发布日期”:“/日期(1355250600000)/”,“类型”:“惊悚”,“价格”:10}]})

1 个答案:

答案 0 :(得分:0)

返回的JSONP中必须有回调函数名称。我在这里看到的输出没有任何函数名称。您需要更改服务器端代码。