如何将数据从 Web 服务绑定到 Kendo UI 移动(IOS)。我尝试使用 Web 服务,页面显示为空白,当我直接绑定数据时,它向我显示 html 页面中的数据(注释数据)。谁能给我任何示例代码或任何示例。
在这里,我提供了我尝试过的代码
html页面中的代码
<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">
$(document).ready(function (){
var dataS = new kendo.data.DataSource({
transport: {
read: {
type: 'GET',
url: 'mobileAppWebService.asmx/EmployeeNames',
dataType: 'json',
data: '{}',
contentType: 'application/json; charset=utf-8'
},
schema: {
data: "d"
}
}
});
debugger
$("#flat-listview").kendoMobileListView({
dataSource: dataS,
template: "${ename}"
});
// var dataSource = ["Sashimi salad", "Chirashi sushi", "Seaweed salad", "Edamame", "Miso soup", "Maguro", "Shake", "Shiromi", "Tekka maki", "Hosomaki Mix", "California rolls", "Seattle rolls", "Spicy Tuna rolls", "Ebi rolls", "Chicken Teriyaki", "Salmon Teriyaki", "Gohan", "Tori Katsu", "Yaki Udon"];
// function mobileListViewDataBindInitFlat() {
// $("#flat-listview").kendoMobileListView({
// dataSource: dataSource,
// endlessScroll: true
// });
// };
});
</script>
<script type="text/javascript">
var app = new kendo.mobile.Application(document.body);
</script>
Web服务中的代码
SqlConnection con = new SqlConnection("Data Source=SHANKAR-PC\\SQLEXPRESS; Initial Catalog=Occumen;Integrated Security=True");
[WebMethod]
public List<EmpNames> EmployeeNames()
{
SqlDataAdapter da = new SqlDataAdapter("select ename from emp", con);
DataSet ds = new DataSet();
da.Fill(ds, "names");
return LstEmpNames(ds);
}
public List<EmpNames> LstEmpNames(DataSet ds)
{
List<EmpNames> objenamelst = new List<EmpNames>();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
EmpNames objemp = new EmpNames();
objemp.ename = ds.Tables[0].Rows[i][0].ToString();
objenamelst.Add(objemp);
}
return objenamelst;
}