My question is ow to create a view-model object of a JSON data (parsed from a .json file) using KendoObservable object ?
var viewModel = kendo.observable({
dtSource: new kendo.data.DataSource({
transport: {
read: {
url: "/data/SiteMaster.json",
dataType: "json"
}
},
schema: {
model: {
fields: {
siteName: { type: "string" },
address: { type: "string" },
status: { type: "string" },
persons: { type: "string" }
}
}
}
}),
});
I'm binding the viewmodel object to the div element at a later point of time
kendo.bind($("div"), viewModel);
However, I'm not able to read the content from the JSON file
I get dtSource
is not defined when I try to debug on Developer Console on browser
The SiteMaster JSON file that I'm reading is below
{
"siteMaster":[
{
"siteName" : "SHG",
"filename" : "site1.json",
"persons": 1,
"status": "70%",
"address": "BergesHill Road",
},
{
"siteName" : "ABC",
"filename" : "site2.json",
"persons": 1,
"status": "67%",
"address": "BergesHill Road",
},
{
"siteName" : "XYZ",
"filename" : "site3.json",
"persons": 1,
"status": "80%",
"address": "BergesHill Road",
},
{
"siteName" : "Scots",
"filename" : "site4.json",
"persons": 1,
"status": "80%",
"address": "BergesHill Road",
}]
}