I using datasource to display some data from API(JSON data) in my kendo template. If i get JSON data as an array, its replacing the template and rendered properly into the template and created right data format. But if i get any single JSON data object(not an array format). It is not replacing the template. Is data source will handle only array format of JSON. See the below code data sample with array and without array format.
Below JSON data its replacing properly into my kendo template.
But if i get response format like below JSON data, It is not rendering to my kendo template
My Kendo template view file
My viewModel
Help me to load single json string data to my kendo template.
Below JSON data its replacing properly into my kendo template.
[{"EmployeeId":"2","EmployeeCode":"ASD","EmployeeName":"ASD","Description":"","CreateDate":"9/13/2013 12:00:00 AM","StatusId":"4","IsActive":"True"}]
But if i get response format like below JSON data, It is not rendering to my kendo template
{"EmployeeId":"2","EmployeeCode":"ASD","EmployeeName":"ASD","Description":"","CreateDate":"9/13/2013 12:00:00 AM","StatusId":"4","IsActive":"True"}
My Kendo template view file
<
script
id
=
"projectDetailsTemplate"
type
=
"text/x-kendo-template"
>
<
h3
class
=
"item-title"
>${EmployeeName}</
h3
>
</
script
>
My viewModel
getEmployeeDetail: function(id){
var EmpData= new kendo.data.DataSource({
transport: {
read: {
url: "http://127.0.0.1/api/index.php",
dataType: "json",
cache: false
}
},
schema: {
errors: "error"
},
error: function(e) {
utils.hideLoading();
alert("bad request");
}
});
return EmpData;
}