1

I want a Kendo List View for showing images, so Here is my KendoUI list view, but the values which I am fetching from controller is not binding in template.please help..

         <div id="example">

    <div class="demo-section">
        <div id="listView"></div>
        <div id="pager" class="k-pager-wrap"></div>
    </div>
    @section scripts{
    <script src="~/scripts/kendo/kendo.all.min.js"></script>
    <script type="text/x-kendo-template" id="template">
        <div class="product">
            <img src="#= Title #" alt="#: Title # image" />
            <h3>#:Title#</h3>

        </div>
    </script>

    <script>
        $(function () {
            var dataSource = new kendo.data.DataSource({
                transport: {
                    read: {
                        url: "/api/my/thumbnail",
                        dataType: "json"
                    }
                },
                pageSize: 15,
            });

            $("#pager").kendoPager({
                dataSource: dataSource
            });

            $("#listView").kendoListView({
                dataSource: dataSource,
                template: kendo.template($("#template").html())
            });
        });
    </script>
}
    <style scoped>
        .demo-section {
            margin: 20px auto;
            border: 0;
            background: none;
            width: 577px;
        }

        #listView {
            padding: 10px;
            margin-bottom: -1px;
            min-width: 555px;
            min-height: 510px;
        }

        .product {
            float: left;
            position: relative;
            width: 111px;
            height: 170px;
            margin: 0;
            padding: 0;
        }

            .product img {
                width: 110px;
                height: 110px;
            }

            .product h3 {
                margin: 0;
                padding: 3px 5px 0 0;
                max-width: 96px;
                overflow: hidden;
                line-height: 1.1em;
                font-size: .9em;
                font-weight: normal;
                text-transform: uppercase;
                color: #999;
            }

            .product p {
                visibility: hidden;
            }

            .product:hover p {
                visibility: visible;
                position: absolute;
                width: 110px;
                height: 110px;
                top: 0;
                margin: 0;
                padding: 0;
                line-height: 110px;
                vertical-align: middle;
                text-align: center;
                color: #fff;
                background-color: rgba(0,0,0,0.75);
                transition: background .2s linear, color .2s linear;
                -moz-transition: background .2s linear, color .2s linear;
                -webkit-transition: background .2s linear, color .2s linear;
                -o-transition: background .2s linear, color .2s linear;
            }

        .k-listview:after {
            content: ".";
            display: block;
            height: 0;
            clear: both;
            visibility: hidden;
        }
    </style>
</div>

and here is my data ,

Items: [,…]

0: {ID:148, Name:Thumbnail, Profiles:null, ContentID:0, Title:http://img.youtube.com/vi/wLbA9Dsnyik/0.jpg,…}
1: {ID:149, Name:Thumbnail, Profiles:null, ContentID:0, Title:http://img.youtube.com/vi/wLbA9Dsnyik/0.jpg,…}
2: {ID:150, Name:Thumbnail, Profiles:null, ContentID:0, Title:http://img.youtube.com/vi/wLbA9Dsnyik/2.jpg,…}
3: {ID:151, Name:Thumbnail, Profiles:null, ContentID:0, Title:http://img.youtube.com/vi/FjBwQtSEGEw/0.jpg,…}

Now these data is not getting bind in template.

4

1 に答える 1

0

テンプレートの = 記号を : 記号に更新してください。下記を参照してください:

<script type="text/x-kendo-template" id="template">
    <div class="product">
        <img src="#: Title #" alt="#: Title # image" />
        <h3>#:Title#</h3>
    </div>
</script>
于 2014-07-18T13:31:46.003 に答える