how to bind the data from web service to Kendo UI mobile (IOS).I have tried using the web service the page is displaying blank and when i’m binding data directly it is showing me the data in the html page(the commented data).Can anyone provide me any sample code or any examples.
here i’m providing my code which i have tried
code in html page
<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>
code in web service
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;
}
1 Answer