【问题标题】:Kendo UI List View not displaying dataKendo UI 列表视图不显示数据
【发布时间】:2013-05-02 07:02:20
【问题描述】:

我使用剑道 UI 列表视图。但即使我使用数据源,我在列表视图中也看不到任何数据。

谁能帮帮我?

这是我的代码,

创建了一个 div #listView 和一个模板。然后尝试将数据绑定到列表视图

<div id="listView"></div>

这是我使用的模板

使用 Kendo UI 创建的模板

<script type="text/x-kendo-tmpl" id="template" >
    <div class="product">     
        <h3>#:title#</h3>
        <p>#:kendo.toString(year, "c")#</p>
    </div>
</script>

我这里绑定数据源

虽然我绑定了数据,但这不起作用。有没有其他绑定数据的方式

var dataSource1 = new kendo.data.DataSource({
    transport: {
        read: {
            dataType: "json",
            data: [
                { title: "Star Wars: A New Hope", year: 1977 }, 
                { title: "Star Wars: The Empire Strikes Back", year: 1980}
            ]  
        }
    }
});

$("#listView").kendoListView({
    dataSource: dataSource1,
    template: kendo.template($("#template").html())
});

【问题讨论】:

    标签: kendo-ui


    【解决方案1】:

    由于您将列表视图绑定到本地数据,因此无需调用传输...只需将数据直接绑定到数据源即可:

    var dataSource1 = new kendo.data.DataSource({
        data: [
            { title: "Star Wars: A New Hope", year: 1977 }, 
            { title: "Star Wars: The Empire Strikes Back", year: 1980}
        ]  
    });
    

    您可以在此处查看数据源的演示页面:http://demos.kendoui.com/web/datasource/index.html

    PS:顺便说一下,格式“c”是用于货币的(参见documentation)。在这里您可以直接调用模板中的年份:#:year#

    【讨论】:

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