I'm trying to get a datasource to load a file that contains JSON data. This is based off the Demos on the site.
Here is how I create and load the datasource:
And here is the filter.json file:
I've have removed stuff out that is not needed to illustrate the problem. The datasource seems to be blank and does not contain any date.
When I copy the data from the file and dump it in code as a variable and tell the datasource to use it, it works fine. Telling it to read from the file however seems hopeless. I've compared it to the samples and read the docos (not very useful BTW) and am stuck.
The JSON data is fine in the file and works with other things (non-Kendo). I'm using IE9.
Here is how I create and load the datasource:
<
script
>
$(document).ready(function() {
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "filters.json",
dataType: "json"
}
},
change: function() {
// subscribe to the CHANGE event of the data source// do stuff here...
});
// read data from the "movies" array
dataSource.read();
});
</
script
>
And here is the filter.json file:
[{id:
"oflc"
,title:
"Classification"
,items:[{title:
"root"
,values:
"CTC,G,PG,M,MA,R"
}]},{id:
"drwho"
,title:
"Favourite Doctor"
,items:[{title:
"Classic"
,values:
"William Hartnell,Patrick Troughton,Jon Pertwee,Tom Baker,Peter Davison,Colin Baker,Sylvester McCoy,Paul McGann"
},{title:
"2005+"
,values:
"Christopher Eccleston,David Tennant,Matt Smith"
},{title:
"Non-canon"
,values:
"Peter Cushing"
}]},{id:
"q"
,title:
"Search term"
,items:[{title:
"root"
,values:
"ANY"
}]},{id:
"format"
,title:
"Format"
,items:[{title:
"root"
,values:
"3D Blu-ray,Blu-ray,DVD"
}]},{id:
"companion"
,title:
"Favourite Companion"
,items:[{title:
"Classic"
,values:
"Mary Tamm_Lala Ward[Romana],John Leeson[K9],Nicola Bryant[Peri],Katy Manning[Jo Grant]"
},{title:
"2005+"
,values:
"Karen Gillan[Amy Pond]"
}]},{id:
"price"
,title:
"Price"
,items:[{title:
"root"
,values:
"<20[Under $20]"
}]}]
I've have removed stuff out that is not needed to illustrate the problem. The datasource seems to be blank and does not contain any date.
When I copy the data from the file and dump it in code as a variable and tell the datasource to use it, it works fine. Telling it to read from the file however seems hopeless. I've compared it to the samples and read the docos (not very useful BTW) and am stuck.
The JSON data is fine in the file and works with other things (non-Kendo). I'm using IE9.