KendoUI Mobile 如何获取远程数据并绑定



样子丑了点。。。。。



1.首先引入javascript文件 kendo.all.min.js,有了它,我们不需要再引入特定的kendoUI了


2.然后仿照kendoUI文件夹里datasourc 的例子定义一个数据源(dataSource)

代码示例:

  var ds = new kendo.data.DataSource({
					transport: {
						read: {
							// the remote service url
							url: "http://localhost:3458/DataService/GetMetricCharts",

							// JSONP is required for cross-domain AJAX
							dataType: "jsonp",

							// additional parameters sent to the remote service
							data: {
								aggregationType: '60-avg',
								timeRange:'sel',
								metricid:'34',
								stDate:'2011-10-29T16:00:00.000Z',
								enDate:'2012-02-08T02:25:55.196Z'

							}
						}
					},
					// describe the result format
					schema: {
						// the data which the data source will be bound to is in the "results" field
						data: ""
					}
         });


3.定义模板:

  <script id="customListViewTemplate" type="text/x-kendo-template">
        <h3 class="item-title">#= m1 #</h3>
        <p class="item-info">#= DateTime #</p>
    </script>



4.jquery构造函数的时候渲染就可以了,lz做的是list控件。

  function mobileListViewTemplatesInit() {
        $("#custom-listview").kendoMobileListView({
            dataSource: ds,
            template: $("#customListViewTemplate").html()
           // headerTemplate: "<h2>Letter ${m1}</h2>"
        });
    }

5.最后附html及样式代码:

   <link href="lib/shared/styles/examples.css" rel="stylesheet"/>
        <link href="lib/shared/styles/examples-offline.css" rel="stylesheet"/>
        <link href="lib/source/styles/kendo.common.css" rel="stylesheet"/>
        <link href="lib/source/styles/kendo.default.css" rel="stylesheet"/>
        <script src="lib/js/jquery.min.js"></script>
        <script src="lib/js/kendo.all.min.js"></script>
        <link href="lib/styles/kendo.mobile.all.min.css" rel="stylesheet" />

    <a href="../index.html">Back</a>
    <div data-role="view" id="listview-templates" data-init="mobileListViewTemplatesInit" data-title="ListView">
    <div class="head"> </div>
    <ul id="custom-listview"></ul>
</div>


如此我们便可以做出一个简单的list界面,其中数据由wcf传出,在客户端得到。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值