0

我正在使用 Web 服务从数据库中检索值。我编写了用于将列表值从 Web 服务绑定到移动列表视图的书面 Fallowing 代码。但是值未显示在列表视图中。从数据库绑定数据是否有任何问题。

<div data-role="view" id="flat" data-init="mobileListViewDataBindInitFlat" data-title="ListView"
    data-layout="databinding">
    <ul id="flat-listview">
    </ul>
</div>    

<script type="text/javascript">  
    $(function () {
        var dataS = new kendo.data.DataSource({
            transport: {
                read: {
                    type: 'POST',
                    url: 'mobileAppWebService.asmx/EmployeeNames',
                    dataType: 'json',
                    data: '{}',
                    contentType: 'application/json; charset=utf-8'
                },
                schema: {
                    data: 'd'
                }
            }
        });

        $("#flat-listview").kendoMobileListView({
            dataSource: dataS,
            template: "${ename}"
        });

    });       
</script>
<script>
    var app = new kendo.mobile.Application(document.body);
</script>                 
4

1 回答 1

0
<div data-role="view" id="grouped" data-init="mobileListViewDataBindInitGrouped"
    data-transition="" data-title="ListView" data-layout="databinding">
    <ul id="grouped-listview">
    </ul>
</div>
<script type="text/x-kendo-template" id="ListViewTemplate">
    <div class="GetEmployeeData">
        <p>${EName}</p>
    </div>
</script>
<script type="text/javascript">
function mobileListViewDataBindInitFlat() {
$.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "MobileAppService.asmx/GetEmployeeData",
            dataType: "json",
            success: function (data) {
                $("#flat-listview").kendoMobileListView({
                    dataSource: data.d,
                    template: $("#ListViewTemplate").html()
                });
            },
            failure: function (msg) {
                alert(msg);
            }
        });
    }
  var app = new kendo.mobile.Application();

</script>

试试这样

于 2012-12-19T04:46:08.073 回答