【问题标题】:Kendo UI Mobile Listview always display [object Object]Kendo UI Mobile Listview 总是显示 [object Object]
【发布时间】:2013-11-19 15:49:27
【问题描述】:

我正在使用 Kendo UI Listview 控件来显示来自 WCF 服务的类别数据。问题始终是列表视图,而不是显示类别的“名称”,而是显示 [object Object]。

服务返回的Json数据是这样的

d

               Items

                          ID=1

                          Name=Sports

                          IsActive=true

HTML 代码:

<body>
<div data-role="view" data-init="mobileListViewPullWithEndless">
    <ul id="grouped-listview"></ul>
</div>
<script>
    var categoriesTransport = new kendo.data.RemoteTransport({
        read: {
            url: "http://localhost:11124/Services/PublishingMobileService.svc/GetAllCategories", //specify the URL which data should return the records. This is the Read method of the Products.svc service.
            contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
            dataType: 'json',
            type: "POST" //use HTTP POST request as the default GET is not allowed for svc
        },
        parameterMap: function (data, operation) {
            if (operation != "read") {
                // web service method parameters need to be send as JSON. The Create, Update and Destroy methods have a "products" parameter.
                return JSON.stringify(data);
            } else {
                return JSON.stringify(data);
            }
        }
    });
    function mobileListViewPullWithEndless(e) {
        $("#grouped-listview").kendoMobileListView({
            height: 400,
            dataSource:kendo.data.DataSource.create( {
                schema: {
                    data: "d.Items", // svc services return JSON in the following format { "d": <result> }. Specify how to get the result.                     
                },
                transport: categoriesTransport,
                template: $("#endless-scrolling-template").text(),
            }),
        });
    }
</script>
<script type="text/x-kendo-tmpl" id="endless-scrolling-template">
    <div>
        <h3>#:ID#</h3>
    </div>
</script>
<script>
    var app = new kendo.mobile.Application(document.body);
</script>

你能帮忙吗?

【问题讨论】:

    标签: wcf listview kendo-mobile


    【解决方案1】:

    我知道这个问题有点老了,但供将来参考:

    我最近在没有模板的情况下绑定到 observable 时遇到了这个确切的问题。像你一样添加模板给了我同样的问题,而像这样添加是有效的:

    <ul id="accomodations-list" 
        data-role="listview" 
        data-style="inset"
        data-bind="source:accommodations"
        data-template="template"></ul>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-15
      相关资源
      最近更新 更多