Kendo ListView无法正常工作

时间:2015-04-23 08:52:14

标签: listview kendo-ui

我的Kendo UI Core ListView由于某些原因无法正常工作,我无法弄清楚原因:

<div id="events-upcoming"></div>

<script type="text/x-kendo-template" id="events-template">
    <div class="event">
        <p>#: Title #</p>
    </div>
</script>

<script>
    $(document).ready(function () {                      

        var upcomingEvents = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "http://localhost/supersavings/services/eventservice.asmx/GetFutureEventsByCompanyName",
                    type: "post",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    data: {
                        companyName: "admin",
                        currentDate: "1/1/2015"
                    }
                },
                parameterMap: function (options) {
                    return kendo.stringify(options); // kendo.stringify serializes to JSON string
                }
            },
            schema: {
                data: "d"
            }
        });

        $("#events-upcoming").kendoListView({
            datasource: upcomingEvents,
            template: kendo.template($("#events-template").html())
        });
    });
</script>

我的JSON数据如下:

{
   "d":[
      {
         "__type":"SSEvent",
         "EventID":7,
         "Title":"Test Title",
         "StartDateTime":"/Date(1426212900000)/",
         "EndDateTime":"/Date(-62135578800000)/",
         "Description":null,
         "Link":null,
         "UseCurrentLocation":false,
         "UseProfileLink":false,
         "UserID":0,
         "VenueName":"",
         "VenueAddress":null,
         "VenueCity":null,
         "VenueState":null,
         "VenueZip":null,
         "CompanyDisplayName":null,
         "CompanyAddress":null,
         "CompanyAddress2":null,
         "CompanyCity":null,
         "CompanyState":null,
         "CompanyZip":null
      }
   ]
}

DataSource有效。我已成功将其手动绑定到模板。由于某种原因,ListView不想工作。

1 个答案:

答案 0 :(得分:0)

这是一个愚蠢的错误。在ListView数据源中应该是DataSource。唯一的问题是小写字母S.我希望有一个调试器或工具可以捕获那些外壳或拼写错误,如Visual Studio与C#一样。